Create a Java program that uses methods. In the main method, the program must prompt the user to enter an integer number from 1 to 20. Then, the program must call a method named “guess” that receives the integer number and generates a random number (integer) from 1 to 20. The method (guess) must print “Correct!!” if the random number is equal to the number received from the main method. Otherwise, the method must print “Incorrect.”
Use the following header:
public static void guess (int x)
{
}
Requirements Specification
The program must satisfy the following requirements:
• It must ask the user to enter an integer between 1-20.
• Call a method named “guess” that generates a random number between 1-20.
• The method “guess” must compare the two numbers and print either “Correct” or “Incorrect”.