Question
import java.util.Scanner; import java.util.Random; public class Guess { public static void main(String[] args) { int numToGuess; //Number the user tries to guess int guess; //The
import java.util.Scanner; import java.util.Random;
public class Guess { public static void main(String[] args) { int numToGuess; //Number the user tries to guess int guess; //The user's guess
Random generator = new Random();
//randomly generate the number to guess
//print message asking user to enter a guess
//read in guess while ( ) //keep going as long as the guess is wrong { //print message saying guess is wrong //get another guess from the user }
//print message saying guess is right } }
File Guess.java(given above) contains the skeleton for a program that uses a while loop to play a guessing game. (This problem is described in the previous lab exercise.) Revise this program so that it uses a do ... while loop rather than a while loop. The general outline using a do... while loop is as follows: ^^^^^^^^^^^^^^^^^^^^^^^
// set up (initializations of the counting variables) ....
do
{
// read in a guess ...
// check the guess and print appropriate messages
...
}
while ( condition );
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started