Hello, I'm new to Java and I was wondering how you could modify the code further by ending the program when EITHER the user successfully guesses OR chooses to end the game in response to a prompting question such as "Would you like to continue testing or stop playing?". If user stops playing print a consolation message, i.e. "Thanks for playing, please try again." Thank you for your help.
/*
* Guess the Number
*/
import java.io.Console;
import java.util.Random;
public class numberprojectloop
{
public static void main(String[] args) {
int computerNumber;
int yourGuess;
Random myRandom = new Random();
int benchmark;
int tryAgain;
benchmark = 14;
// get the computer's number between 1 and 10
computerNumber = myRandom.nextInt(10) + 1;
System.out.println("I'm thinking of a number between 1 and 10.");
do
{
// get your guess
yourGuess = Typeit.inInt("What do you think it is?");
// get clues and tips to help your reach the answer
System.out.println("My number is "+(Math.abs(benchmark-computerNumber)+" less than 15"));
if (yourGuess == computerNumber)
{
System.out.println("You got it!! That's my number!");
}
else if (Math.abs(yourGuess - computerNumber) <= 1)
{
System.out.println("Ouch !! You're burning up!! You're one number away!!");
}
else if (Math.abs(yourGuess - computerNumber) <= 2)
{
System.out.println("You're hot!! You're two numbers away!!");
}
else if (Math.abs(yourGuess - computerNumber) <= 3)
{
System.out.println("You're warm!! You're three numbers away!! ");
}
else
{
System.out.println("Brr!! You're freezing!! You're more than three numbers away!!");
}
System.out.println("Would you like to try again?");
}
//keeps the loop running until you get the correct answer
while (yourGuess != computerNumber);
{
}
}
}

