Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

File Guess,java contains a skeleton for a program to play a guessing game with the user. The program should randomly generate an integer between 1

image text in transcribed
image text in transcribed
File Guess,java contains a skeleton for a program to play a guessing game with the user. The program should randomly generate an integer between 1 and 10, then ask the user to try to guess the number. If the user guesses incorrectly, the program should ask them to try again until the guess is correct; when the guess is correct, the program should print a congratulatory message 1. Using the comments as a guide, complete the program so that it plays the game as described above. 2. Modify the program so that if the guess is wrong, the program says whether it is too high or 3. Now add code to count how many guesses it takes the user to get the number, and print this 4. Finally, count how many of the guesses are too high and how many are too low. Print these 5. Revise this program so that it uses a do while loop rather than a while loop. The general too low. You will need an if statement (inside your loop) to do this. number at the end with the congratulatory message. values, along with the total number of guesses, when the user finally guesses correctly. outline using a do... while loop is as follows /I set up (initializations of the counting variablea) do // read in a guess // check the guess and print approprlate messagea while condition ); A key difference between a while and a do... while loop to note when making your changes is that the body of the do... while loop is executed before the condition is ever tested. In the while loop version of the program, it was necessary to read in the user's first guess before the loop so there would be a value for comparison in the condition. In the do... while this "priming" read is no longer needed. The user's guess can be read in at the beginning of the body of the loop

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Peter Rob, Carlos Coronel

3rd Edition

0760049041, 978-0760049044

More Books

Students also viewed these Databases questions