Homework #3
Due Friday, February 16th at 5pm
Note: bold text in the examples is input from the user.
Example:
% a.out Give me a number: 6.4 Give me another number: 2.8 Guess the sum: 9.2 Right! Another? y Give me a number: 6.4 Give me another number: 1.6 Guess the result: 7 Wrong! Another? n
Example:
% a.out Give me a number: 6.4 Give me an operator: - Give me another number: 2.8 Guess the result: 3.6 Right! Another? y Give me a number: 6.4 Give me an operator: / Give me another number: 1.4 Guess the result: 4 Wrong! Another? n
Also, won't it be fun to keep score? Of course it will, so have the program print the score when it asks if you want to keep playing.
Example:
% a.out Pick a number: 156 Now let your shoe guess a factor: 3 Yes, 3 is indeed a factor of 156. Now let your shoe pick a number: 19 And you pick a factor: 3 Nope, 3 is not a factor of 19. Score is 1 for your shoe, 0 for you. Keep playing? y Pick a number: 154 Now let your shoe guess a factor: 11 Yes, 11 is indeed a factor of 154. Now let your shoe pick a number: 17 And you pick a factor: 1 Sorry, 1 is a factor of 17, but it's too easy. Score is 2 for your shoe, 0 for you. Keep playing? n You have lost the game to your shoe.