Answer:
Explanation:
The following code is written in Java. It creates the two methods as requested using the Scanner and Random built-in classes in Java. Once the loop is completed and the highestNum is calculated, then the displayResults method is called to print out all the information in the correct format. The output of the program can be seen in the attached image below.
import java.util.Random;
import java.util.Scanner;
class Brainly {
static int highestNum = 0;
static int userInput;
static int sumOfNums = 0;
public static void main(String[] args) {
userData();
displayResults();
}
private static void userData() {
Scanner in = new Scanner(System.in);
Random rand = new Random();
System.out.println("Enter a number between 9 and 20: ");
userInput = in.nextInt();
if ((userInput >= 9) && (userInput <= 20)) {
for (int i = 0; i < userInput; i++) {
int num = rand.nextInt(100);
if (num > highestNum) {
highestNum = num;
}
sumOfNums += num;
}
}
}
public static void displayResults() {
System.out.println("There were " + userInput + " numbers generated");
System.out.println("The highest number generated is " + highestNum);
System.out.println("The sum of the numbers is " + sumOfNums);
int average = sumOfNums / userInput;
System.out.println("The average of the numbers is " + average);
}
}