Recall how to obtain a random number. For example, the following statement generates a random number between

Question:

Recall how to obtain a random number. For example, the following statement generates a random number between the constants MIN and MAX inclusive and assigns it to a variable named random:

random = MIN + (int) (Math.random() * MAX);

Write a program that declares final values for MIN and MAX within its main() method and passes the values to a method that displays a message asking the user to guess a value between MIN and MAX. Accept the user’s guess and return it to the main() method. Set a boolean variable to true if the user guessed the value and false if the user did not guess the value. Call a method that accepts the random value, the user’s guess value, and the boolean value and then displays all the values as well as how far away the user’s guess was from the random number. Save the file as RandomGuessMatchWithMethods.java.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question

Java Programming

ISBN: 9780357673423

10th Edition

Authors: Joyce Farrell

Question Posted: