Question: i did a java lab for random compliments and the feedback i got was in the main method i called two input methods when i

i did a java lab for random compliments and the feedback i got was in the main method i called two input methods when i was only allowed to call one, and then it was cited again later in the code that i could only write one input method and wrote two. i have included my code below. could someone explain how to only have one input method? the methods in question are getSeed and getQuantityOfCompliments
import java.util.Random;
import java.util.Scanner;
public class RandomCompliment_Part1{
public static void main(String[] args){
// Displays welcome message
System.out.println("Welcome to the Random Complimenter program.
");
// Instantiate the scanner
Scanner scanner = new Scanner(System.in);
// Getting the seed for the random number generator
int seed = getSeed(scanner);
// Instantiate the random object
Random random = new Random(seed);
// Consume newline
scanner.nextLine();
// Variable to store the quantity of compliments
int quantityOfCompliments;
// Loop to continuously ask for compliments until the user enters 0
do {
// Prompting the user for the quantity of compliments
quantityOfCompliments = getQuantityOfCompliments(scanner);
// If the user input is not 0, generate and output compliments
if (quantityOfCompliments !=0){
outputCompliments(quantityOfCompliments, random);
}
} while (quantityOfCompliments !=0);
// Close the scanner
scanner.close();
// Displays farewell message
System.out.println("
Have a great day!
");
}
// Method to prompt the user for a seed
public static int getSeed(Scanner scanner){
// Asking the user to enter a seed for the random number generator
System.out.println("Enter a seed for the random number generator.");
// Returning the seed entered by the user
return scanner.nextInt();
}
// Method to prompt the user for the quantity of compliments
public static int getQuantityOfCompliments(Scanner scanner){
// Asking the user how many compliments they would like
System.out.println("
How many compliments would you like? ('0' to quit)");
// Returning the quantity of compliments entered by the user
return scanner.nextInt();
}
// Method to generate a random compliment
public static String generateCompliment(Random random){
// Generating a random integer between 0 and 2 to select a compliment
int complimentIndex = random.nextInt(3);
// Switching between different compliments based on the random
// integer generated
switch (complimentIndex){
case 0:
return "You are soooooo good looking.";
case 1:
return "You ... are ... #1.";
case 2:
return "You're pretty awesome.";
default:
return ""; // This case should never happen
}
}
// Method to output compliments
public static void outputCompliments(int quantity, Random random){
// Loop to generate and output the specified quantity of compliments
for (int i =0; i < quantity; i++){
// Generating a random compliment
String compliment = generateCompliment(random);
// Printing the compliment
System.out.println(compliment);
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!