Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Step: 3

blur-text-image

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

Students also viewed these Databases questions

Question

When is it appropriate to use a root cause analysis

Answered: 1 week ago

Question

12-5 How will MIS help my career?

Answered: 1 week ago