Write a program that selects a random number between 1 and 5 and asks the user to guess the number. Display a message that indicates the difference between the random number and the user’s guess. Display another message that displays the random number and the Boolean value true or false depending on whether the user’s guess equals the random number.

Respuesta :

CPED

Answer:

Following is given the program code as required:

Explanation:

  • Initially a class is created name RandomGuessMatch.java
  • An instance for scanner class is created in main method.
  • Now the upper and lower bounds for guess are given by variables MIN (1) and MAX(5).
  • Now user will be allowed to guess the number.
  • The difference between the guessed number and actual number is calculated.
  • This will tell the compiler weather to print correct or incorrect.

i hope it will help you!

Ver imagen CPED
Ver imagen CPED