I wrote a program that looks something like this
System.out.println ("What would you like to do?");
String task = sc.nextLine();
Then based on the input, I have a bunch of while loops for each input
while (task.equals("example")) {
//do something
System.out.println ("What would you like to do now?");
task = sc.nextLine();
}
while (task.equals("example 2")) {
//do something
System.out.println ("What would you like to do now?");
task = sc.nextLine();
}
etc. At the end of each loop the user can input what they want to do next, and depending on what they say, the corresponding while loop should execute.
But I can't get a while loop that's above another one to execute. So if I'm in the "example" loop, I can execute the "example 2" loop afterwards because it is below it. But if I'm in the "example 2" loop, I can't execute the "example" loop which is above it. Is there any way around this?