How to make a program back to a certain line? (new programmer)
I'm a computer programming student in High School looking for some help, in this assignment I have to make a choose your own ending game using if statements, I want to make it so when the user inputs a certain choice it will go to the next statement, but the thing is the statement is behind the one I want to add is a few statements behind, here's what I have so far...
System.out.println("senario1"
+ "\n"
+ "\n1) choice1"
+ "\n2) choice2");
int choice3 = key.nextInt();
if (choice3 == 1)
{
System.out.println("senario2"
+ "\n"
+ "\n1) choice3"
+ "\n2) choice4"
+ "\n3) choice5");
int choice4 = key.nextInt();
if (choice4 == 3)
{
}
}
else if (choice3 == 2)
{
System.out.println("senario3"
+ "\n"
+ "\n1) choice6."
+ "\n2) choice7."
+ "\n3) choice8."
+ "\n4) choice9.");
}
I want to make it so that if the user chooses choice3 it will send them to senario3 instead of continuing forward. I tried to do a one of those while-continue ones but I couldn't figure it out and from reading up I don't think that's the right solution. Any help is appreciated! I'm using Java and my IDE is Eclipse if that helps at all.
Explain to me like a baby because I am dumb! Thank you in advance!
from Recent Questions - Stack Overflow https://ift.tt/3dDwDAX
https://ift.tt/eA8V8J
Comments
Post a Comment