## Binary Branching using IF..THEN

1. Write fragments of code which accept an integer value from the user as a string and which indicate:
1. if the number is positive, negative or zero.
2. if the number Is divisible by 2 or divisible by 3.
3. the reciprocal of the number (i.e., l/number) as a real number to five decimal places (if it has a reciprocal).

2. Write a segment of code which accepts a character value from the user and which prints out the next letter in the alphabet. If the character 'Z' is typed, the letter 'A' should be returned. If the character typed in is not an uppercase letter, the machine should write 'Not an upper case Letter'.

3. Explain why the following code would be classified as an abuse of the if-then-else statement (include discussion of best and worst case. Rewrite the code properly.
```     var n : integer;
begin
n  := random(6)+1;
if n=l  then writeln('[.]');
if n=2  then writeln('[:]');
if n=3  then writeln('[:.]');
if n=4  then writeln('[::]');
if n=5  then writeln('[:.:]');
if n=6  then writeln('[:::]');```
4. TWO-UP is a game where two coins are tossed and betting occurs based on the resulting faces of the coins. Then two coins are tossed, the results can be classified as follows: coin1 coin2 odds evens heads tails
 Coin 1 Coin 2 ODDS EVENS HEADS TAILS H H NO YES YES NO T T NO YES NO YES H T YES NO NO NO T H YES NO NO NO
Write a small but efficient program that uses a Random(10)+1 call to generate EACH coin, and correctly classifies the pair as ODDS or EVENS, HEADS or TAILS.

5. When mixing colours using the ADDITIVE SPECTRUM, we get the following results:
 RED + GREEN = YELLOW RED + BLUE = MAGENTA BLUE + GREEN = CYAN YELLOW + BLUE = WHITE MAGENTA + GREEN = WHITE CYAN + RED = WHITE
Allocate a character to each of the colours listed above (B=Blue, R=Red etc), then write a program that displays a menu of colour names and their corresponding codes, allows the user to input two colour codes and correctly outputs the NAME and CODE of the resultant colour.

wonko@wonko.info