91.3k views
4 votes
Create a program that generates a random number between 0 and 50. Give the user 5 guesses to get the correct answer.

Have the program repeat until the user quits
Keep score showing the number of games played and correct guess
Display a winning percentage
Basic Outline -
public class RandomNumberGame
{
public static void main(String args[]){
//scanner
//random number between 0 and 50
//int count = 0;
//do
// enter a guess
//determine if correct, higher or lower(if statement)
//count the guesses
//while control of 5 guesses or correct guess
}
}

1 Answer

6 votes

Final answer:

This task involves writing a Java program for a number-guessing game where the user tries to guess a random number between 0 and 50 within 5 attempts. The program repeats until the user quits, keeping score of the games played and the user's success, finally displaying the winning percentage.

Step-by-step explanation:

This programming task involves creating a simple Java program that allows a user to play a number-guessing game. The objective is to create a program that generates a random number between 0 and 50 and have the user attempt to guess the number within 5 tries.

The user can play multiple rounds, and the program keeps track of the number of games played, the number of correct guesses, and displays the winning percentage at the end. Users can continue to play until they choose to quit the game. The game keeps running until the user decides to quit, upon which the final score and winning percentage are displayed back to the user.

User Priyath Gregory
by
7.6k points