Question: Guess the Number Now we will create a number guessing game in which the user specifies a range of numbers. The program will then generate
Guess the Number
Now we will create a number guessing game in which the user specifies a range of numbers. The program will then generate a number within that range and the users guesses what it is. The program will then output the difference between the generated number and the guess.
You will need to use Java's Random class and the seed: 340L so that the numbers will become predictable for testing purposes.
The declaration and initializatoin of the Random variable will look something like this:
Random rand = new Random(340L);
The Random class has a method called nextInt().
For parameters (values given in the parenthises), it can take a maximum value that is exclusive. So if you passed (put in parentheses) the number 5, the generator would give a number 0-4.
Using the user provided max and min, manipulate the Random number generator so that it gives numbers in the range [min,max] (That is the range is inclusive).
Hint: Google is your friend.
Output for this section should look like:
Range: 1-100 The difference between the generated number and your guess: 56 - 25 = 31
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
