Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. # Homework 5
  2.  
  3. Write a program that allows two players to play a guessing game. The program works as follows:
  4. 1. First, player 1 enters the secret number. The program should check that the number is not less than 0 and not greater 99, prompting the user to re-enter the number if needed.
  5. 2. The player 2 begins entering guesses when prompted. The prompt for a guess should inform the user how many guesses they have remaining (7 to start). After they make an incorrect guess, the program should tell them if their guess is greater than or less than the secret number and prompt for another guess (with an updated count of guesses remaining).
  6.  
  7. For the purposes of this assignment, you don't need to worry about hiding the secret number from player 2.
  8.  
  9. ## Sample input/output for a loss:
  10.  
  11. ```
  12. Player 1: Type a number between 0 and 99 and press return (player 2, no peaking!): 101
  13. Secret number cannot be greater than 99. Type a number between 0 and 99 and press return (player 2, no peaking!): 80
  14. Player 2: Type your guess and press return (you have 7 guesses remaining): 14
  15. Your guess was less than the secret number. Type your guess and press return (you have 6 guesses remaining): 81
  16. Your guess was greater than the secret number. Type your guess and press return (you have 5 guesses remaining): 45
  17. Your guess was less than the secret number. Type your guess and press return (you have 4 guesses remaining): 59
  18. Your guess was less than the secret number. Type your guess and press return (you have 3 guesses remaining): 62
  19. Your guess was less than the secret number. Type your guess and press return (you have 2 guesses remaining): 70
  20. Your guess was less than the secret number. Type your guess and press return (you have 1 guesses remaining): 71
  21. Your guess was less than the secret number.
  22. Sorry you are out of guesses :-(
  23. ```
  24.  
  25. ## Sample input/output for a win
  26.  
  27. ```
  28. Player 1: Type a number between 0 and 99 and press return (player 2, no peaking!): 20
  29. Player 2: Type your guess and press return (you have 7 guesses remaining): 50
  30. Your guess was greater than the secret number. Type your guess and press return (you have 6 guesses remaining): 10
  31. Your guess was less than the secret number. Type your guess and press return (you have 5 guesses remaining): 25
  32. Your guess was greater than the secret number. Type your guess and press return (you have 4 guesses remaining): 19
  33. Your guess was less than the secret number. Type your guess and press return (you have 3 guesses remaining): 20
  34. You guessed the secret number :-)
  35. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement