Build an application that will receive a guess and report if your guess is the random number that was generated. Your application will narrow down the choices according to your previous guesses, and continue to prompt you to enter a guess until you guess correctly. Notice that if you divide the choices in half each iteration, you will need at most log:(100) ~ 7 guesses. You will use the utility class RNG.java.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

Java, i have the RNG code already only the RandomNumberGenerator step that I need help with. 

Assignment Deseription
Build an application that will receive a guess and report if your guess is the random
number that was generated. Your application will narrow down the choices according to
your previous guesses, and continue to prompt you to enter a guess until you guess
correctly.
Notice that if you divide the choices in half each iteration, you will need at most
log:(100) - 7 guesses.
You will use the utility class RNG.java.
Concepts tested by this assignment
A driver and a utility class
UML class diagrams or pseudo-code
Java fundamentals, including decision structures, loops
Selection control statements
Repetition control statements
Input validation loops (in RNG.java)
Relational and logical operators
Random number generation (in RNG.java)
Classes
Data Element Class – RNG
Provided
This file will generate a random number between 1 and 100
Note that the method "rand" is a static method, so the java file does not need to be instantiated to
use it. Call rand with the following: RNG.rand(100) to generate a random number between 0
and 99.
Study this class. You will want to use four methods from this class: rand, resetCount, getCount
and inputValidation.
Driver Class – RandomNumberGuesser
Student created
This is the driver class for RNG that contains a main method.
The driver is responsīble to:
o print a header
o ask the user for an initial guess of the Random Number between 0 and 100.
o Print out the result for that guess using the methods from the RNG class.
Allow user to give another guess between the previous low and high guesses.
• Display the number of guesses
When user guesses correctly, ask if the user wants to try another round.
Print the Programmer's name at the end
Refer to the program sample run for more clarification.
Data Validation. The following data is validated by the RNG method inputValidation:
o Guesses must be an integer between the previous low guess and high guess.
Naming.
There should be an attrībute named randNum
o There should be attributes named nextGuess, highGuess, and lowGuess
Transcribed Image Text:Assignment Deseription Build an application that will receive a guess and report if your guess is the random number that was generated. Your application will narrow down the choices according to your previous guesses, and continue to prompt you to enter a guess until you guess correctly. Notice that if you divide the choices in half each iteration, you will need at most log:(100) - 7 guesses. You will use the utility class RNG.java. Concepts tested by this assignment A driver and a utility class UML class diagrams or pseudo-code Java fundamentals, including decision structures, loops Selection control statements Repetition control statements Input validation loops (in RNG.java) Relational and logical operators Random number generation (in RNG.java) Classes Data Element Class – RNG Provided This file will generate a random number between 1 and 100 Note that the method "rand" is a static method, so the java file does not need to be instantiated to use it. Call rand with the following: RNG.rand(100) to generate a random number between 0 and 99. Study this class. You will want to use four methods from this class: rand, resetCount, getCount and inputValidation. Driver Class – RandomNumberGuesser Student created This is the driver class for RNG that contains a main method. The driver is responsīble to: o print a header o ask the user for an initial guess of the Random Number between 0 and 100. o Print out the result for that guess using the methods from the RNG class. Allow user to give another guess between the previous low and high guesses. • Display the number of guesses When user guesses correctly, ask if the user wants to try another round. Print the Programmer's name at the end Refer to the program sample run for more clarification. Data Validation. The following data is validated by the RNG method inputValidation: o Guesses must be an integer between the previous low guess and high guess. Naming. There should be an attrībute named randNum o There should be attributes named nextGuess, highGuess, and lowGuess
There should be an attrībute named randNum
• There should be attributes named nextGuess, highGuess, and lowGuess
Add any necessary methods to modularize your code.
Assignment Details
Your program should respond similar to the following sample runs:
= Example Run 1 (one iteration) =
Enter your first guess
99
Number of guesses is 1
Your guess is too high
Enter your next guess between e and 99
66
Number of guesses is 2
Your guess is too low
Enter your next guess between 66 and 99
73
Number of guesses is 3
Congratulations, you guessed correctly
Try again? (yes or no)
no
Thanks for playing...
Example Run 2 (one iteration, one guess over the limit)
Enter your first guess
2
Number of guesses is 1
Your guess is too low
Enter your next guess between 2 and 100
77
Number of guesses is 2
Your guess is too high
Enter your next guess between 2 and 77
80
>>> Guess must be between 2 and 77.
Try again
44
Number of guesses is 3
Your guess is too high
Enter your next guess between 2 and 44
Number of guesses is 4
Congratulations, you guessed correctly
Try again? (yes or no)
no
Thanks for playing...
Transcribed Image Text:There should be an attrībute named randNum • There should be attributes named nextGuess, highGuess, and lowGuess Add any necessary methods to modularize your code. Assignment Details Your program should respond similar to the following sample runs: = Example Run 1 (one iteration) = Enter your first guess 99 Number of guesses is 1 Your guess is too high Enter your next guess between e and 99 66 Number of guesses is 2 Your guess is too low Enter your next guess between 66 and 99 73 Number of guesses is 3 Congratulations, you guessed correctly Try again? (yes or no) no Thanks for playing... Example Run 2 (one iteration, one guess over the limit) Enter your first guess 2 Number of guesses is 1 Your guess is too low Enter your next guess between 2 and 100 77 Number of guesses is 2 Your guess is too high Enter your next guess between 2 and 77 80 >>> Guess must be between 2 and 77. Try again 44 Number of guesses is 3 Your guess is too high Enter your next guess between 2 and 44 Number of guesses is 4 Congratulations, you guessed correctly Try again? (yes or no) no Thanks for playing...
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Math class and its different methods
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT