Question: Your objective for this assignment is to develop a Java class called GuessGase.java to solve the following problem. A system generates a winning number

Your objective for this assignment is to develop a Java class called GuessGase.java to solve the following 

Below is a sample output of what your code should display when it is executed Welcome to the Guessing Game!

Your objective for this assignment is to develop a Java class called GuessGase.java to solve the following problem. A system generates a winning number randomly within the range of [100, 1000], and the user is given 10 attempts to correctly guess the winning number Here's a compertensive step-by-step explanation 1. Import the necessary libraries The code imports the scanner and Randon classes from the java.util package 2. Generate a random winning number Create a random number generator and set the range for the winning number between 100 and 1000 3. Prompt the user for their guess. Use a Scanner to ask the user to input their guess within the specified range 4. Jnitialize counters: Set up variables to keep track of the number of attempts (counter) and the maximum number of attempts allowed (trials) 5. Start a guess loop. Use a while loop to derate as long as the number of attempts is within the allowed range 6. Compare the user's guess with the winning number Check if the user's guess matches the winning number 7. Display feedback for correct and incorrect guesses If the guess is correct, display a winning message and the number of attempts Exit the loop If the guess is incorrect, provide feedback and ask the user to guess again, adjusting the range accordingly 4 8. End the guess loop if the loop ends due to running out of attempts, display a losing message if necessary and reveal the correct winning number Below is a sample output of what your code should display when it is executed Welcome to the Guessing Game! Guess the winning number between 100 and 1000. Attempt 1/10, enter your guess: 500 Try again, your guess was too high. Attempt 2/10, enter your guess: 258 Try again, your guess was too low. Attempt 3/10, enter your guess: 350 Try again, your guess was too high. Attempt 4/10, enter your guess: 300 Try again, your guess was too low. Attempt 5/10, enter your guess: 325 Try again, your guess was too low. Attempt 6/10, enter your guess: 340 Congratulations! You guessed the winning number 340 in 6 attempts. Welcome to the Guessing Game! Guess the winning number between 100 and 1000. Attempt 1/10, enter your guess: 200 Try again, your guess was too high. Attempt 2/10, enter your guess: 10 Try again, your guess was too low. Attempt 3/10, enter your guess: se Try again, your guess was too low. Attempt 4/10, enter your guess: 60 Try again, your guess was too low. Attempt 5/10, enter your guess: 70 Try again, your guess was too low. Attempt 6/10, enter your guess: 00 Try again, your guess was too low. Attempt 7/10, enter your guess: 00 Try again, your guess was too low, Attempt /10, enter your guess: 100 Try again, your guess was too low. Attempt 0/10, enter your guess: 110 try again, your guess was too low. Attempt 10/10, enter your guess: 120 Try again, your guess was too low. Sorry, you've used all 10 attempts. The winning number was 120.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Java class called GuessGame that implements the steps youve described to create a guessing g... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!