Question
JAVA Develop a program that simulates the high-low game. For each execution of the program, the game will generate a random number in the inclusive
JAVA
Develop a program that simulates the high-low game. For each execution of the program, the game will generate a random number in the inclusive range of 1 to 100. The user will have up to 10 chances to guess the value. The program will keep track of all the users guesses in an array. For each guess, the program will tell the user if his/her guess was too high or too low. If the user is successful, the program will stop asking for guesses, display the list of guesses, and show a congratulatory message stating how many guesses he/she took. If the user does not guess the correct answer within 10 tries, the program will display the list of guesses, and show him/her the correct value with a message stating that he/she was not successful. Regardless of the outcome, the program will give the user a chance to run the program again with a new random number. Method 1: A method that generates the random number to be guessed returns the random number to main. Two parameters are the two numbers needed to generate the random number (1 and 100 in this case). Method 2: This method tells the user if the guess is too low or too high. It will have 2 parameters one for the random number and the second is the user guess. Method 3: This method will get the user guess. It has 2 parameters which will be the valid range the user should guess between (in this case 1 and 100). It will return the users guess as an integer. This method should validate that the users guess is between the two parameters.
THIS IS WHAT I HAVE SO FAR:
package assignment7;
import java.util.Random;
/** * * @author Malek Badwan */ public class Assignment7 { /* A method that generates the random number to be guessed returns the random number to main. Two parameters are the two numbers needed to generate the random number (1 and 100 in this case). Import a random number generator return a random number as int */ public static int getRandom(int low, int high ) { Random generator = new Random ( ); int RanNum = generator.nextInt(100) + 1; return RanNum; } /* display the random number */ private static void Results (int randomNumber,int guess) { } /* */ private static int UserGuess(int low, int high) //validate input { } /* */ public static void main(String[] args) { // TODO code application logic here } }
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