Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 1. Write the game number-guess which takes a number as its argument and returns "higher" if the number guessed is too small, "lower" if it is too big, and "You win!" if it is the correct number. You can decide upon the range for the possible solution set (between 1 and 100, 0 and 1000, etc.). You might want to take a look at the random procedure if you want to let the computer choose the answer. (If you do play with the random procedure, can you find a problem with how it works?)
- Your program must continue in a loop until the user either gets the correct answer or quits the program by pressing CTL-C or by closing the window.
- Example output:
- > (number-guess)
- Enter a number:
- 50
- LOWER
- Enter a number:
- 25
- HIGHER
- Enter a number:
- 38
- HIGHER
- Enter a number:
- 44
- HIGHER
- Enter a number:
- 47
- You win!
- >
- 2. Change your program so that once a game is finished, the user is asked if s/he wants to play another. The program should quit if the letter n is entered and a new game should be played if the user enters the letter y.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement