Question: Hi, I need help developing a program thats a guessing game Modify it so that the program plays a number guessing game with the user.

Hi, I need help developing a program thats a guessing game

Modify it so that the program plays a number guessing game with the user.

i. First, the program picks a random integer between 1 and 100 (inclusive), then it accepts guesses from the user until the user guesses the number correctly. After each incorrect guess, the program will tell the user whether the correct answer is higher or lower than the guess. Once the user types the correct number, the game ends and the program reports how many guesses were made. An example game is shown below:

I'm thinking of a number between 1 and 100...

Your guess? 50

It's lower.

Your guess? 25

It's higher.

Your guess? 35

It's lower.

Your guess? 30

It's higher.

Your guess? 32

It's lower.

Your guess? 31

You guessed it in 6 guesses!

ii. After each game ends and the number of guesses is shown, the program asks the user if he/she would like to play again. Assume that the user will type a oneword string as the response to this question. A new game should begin if the user's response starts with a lower- or upper-case Y. For example, answers such as "y", "Y", "yes", "YES", "Yes", or "yeehaw" all indicate that the user wants to play again. Any other response means that the user does not want to play again. For example, responses of "no", "No", "okay", "0", "certainly", and "hello" are all assumed to mean no.

iii. Once the user chooses not to play again, the program prints overall statistics about all games played: the total number of games, total guesses made in all games, average number of guesses per game (as a real number rounded to the nearest tenth), and best game (fewest guesses needed to win any one game) are displayed.

I'm thinking of a number between 1 and 100...

Your guess? 50

It's higher.

Your guess? 75

It's lower.

Your guess? 65

It's lower.

Your guess? 64

You guessed it in 4 guesses!

Play again? YES

I'm thinking of a number between 1 and 100...

Your guess? 37

You guessed it in 1 guesses!

Play again? y

I'm thinking of a number between 1 and 100...

Your guess? 50

It's lower. Your guess? 25

It's lower. Your guess? 13

You guessed it in 3 guesses!

Play again? No

Your overall results: Total games = 3 Total guesses = 8 Guesses/game = 2.7 Best game = 1

Thank you very much for your help

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!