Question: 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
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
Get step-by-step solutions from verified subject matter experts
