$25
Random Number Guesser
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 until you guess correctly.
Notice that if you divide the choices in half each iteration, you will need at most log2(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 responsible 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.
o Allow user to give another guess between the previous low and high guesses.
o Display the number of guesses
o When user guesses correctly, ask if the user wants to try another round.
o Print the Programmer's name at the end
o Refer to the program sample run for more clarification.
o For testing, you may print out the randomly-generated number.
o In comments, list the author’s name (yours)
• 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.
o There should be an attribute named randNum
o 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) ===========
== Example Run 2 (one iteration, one guess over the limit) ===========
== Example Run 3 (two iterations) ===========
Take screenshots of two runs of your program. Your runs should include feedback on previous low and high guesses, at least one example of a guess not within the previous low and high guesses, and an example of a second try with a new random number. You may use either an IDE or command-line processing. Store your files in the repo you created in GitHub in Lab 1, and take a screenshot of the GitHub repo.