Advertisement
Guest User

Untitled

a guest
Dec 11th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. 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?)
  2.  
  3. 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.
  4.  
  5. Example output:
  6.  
  7. > (number-guess)
  8. Enter a number:
  9. 50
  10. LOWER
  11. Enter a number:
  12. 25
  13. HIGHER
  14. Enter a number:
  15. 38
  16. HIGHER
  17. Enter a number:
  18. 44
  19. HIGHER
  20. Enter a number:
  21. 47
  22. You win!
  23. >
  24. 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