I'm trying to loop through an entire program if the user inputs "y" or "Y" when they are prompted at the end of the program, but I'm getting a "cannot find symbol - variable response" error since the variable I declared is inside the do-while loop, therefore I suppose I can't use it in the condition of the do-while loop. Is there any way to get around this problem and still be able to loop through the program if the user inputs a "y" or "Y"? This is all in the main method and getFileRunStats is the method that contains all other methods from the program.
Here's the relevant code:
public static void main(String[] args) throws IOException {
System.out.println("A program to analyze home field advantage in sports.");
System.out.println();
Scanner keyboard = new Scanner(System.in);
do{
getFileRunStats(keyboard);
System.out.println("Do you want to check another data set?");
System.out.print("Enter Y or y for to analyze another file, anything else to quit: ");
String response = keyboard.nextLine();
}while(response == "Y" || response == "y");
}
Aucun commentaire:
Enregistrer un commentaire