Write a complete program for the user to play a number guessing game. The computer generates a

Question:

Write a complete program for the user to play a number guessing game. The computer generates a random number from 1-10, and the user gets one chance to guess that number. Output a message whether the guessed number was correct. After each game the player will be asked to play another game. When the user decides to stop, the winning percent of games will be displayed. The statement that will generate a random number from 1 to 10 inclusive is:

image text in transcribed

First, define a class that represents one number guessing game which should include the play method that generates a random number, asks the user for input, checks if the user won, and displays the result. Make sure to keep track of the number of games played and the number of games the user won.
Next, implement a main program to play the number guessing game. Use a loop to play the game multiple times. At the conclusion display statistics of games.
Use an option dialog box like the blow for the user input. Option dialog boxes are discussed in Appendix A.7.

image text in transcribed

The user will be notified the result in the message dialog boxes that are similar to the ones shown below:

image text in transcribed

After each game, use a confirmation dialog box discussed in Appendix A. 6 for the user to click on yes or no.

image text in transcribed

When the user clicks no, output the percent of winning games. Example is shown below:

image text in transcribed

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: