Question: This is a simple guessing game. The computer is to generate a random number between 1 and 20. The user is given up to five

This is a simple guessing game. The computer is to generate a random number between 1 and 20. The user is given up to five guess to guess the exact number. After each guess, you are to tell the user if the guessed number is greater then, less than, or equal to the random number. If it is equal, no more guesses should be made. If the user hasnt guessed the number after five tries, display the number with a message that the user should know if by now and terminate the game.

I am thinking of a number between 1 and 20.

Can you guess what it is? 10

Your Guess is low. Try Again: 15

Your Guess is low. Try Again: 17

Your Guess is high. Try Again: 16

Congratulation! You did it.

A possible unsuccessful dialog:

I am thinking of a number between 1 and 20.

Can you guess what it is? 10

Your guess is low. Try again: 20

Your guess is high. Try again: 18

Your guess is high. Try again: 12

Your guess is low. Try again: 14

Sorry. The number was 15.

You should have gotten it by now.

Better luck next time.

Your design for this program should include a separate function to get the users guess, a function to print the unsuccessful message, one to print the successful message and one to print the sorry message.

You may use no loop

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!