I am working on a school project for Intro to CS and I can't post my code because our teacher fails us for getting code checked from StackOverflow. My issue is that in my code with the format :
while (condition){
Do something;
if (new condition){
Do something else;
Wait for input;
Depending on input make while's condition false;
}
This code should wait for input when the if statement is evaluated and it does something else. However, my code does not wait for "Wait for input" step and goes directly to the "Do something" step. Here's a bit of the code. Thank you for your help.
while (inum != 102) {
System.out.println("Enter a number between 1 and 100: ");
inum = input.nextInt();
else if (inum == 101) {
System.out.println("Are you sure you want to quit?");
confirm = input.nextLine();
if (confirm == "yes") {
inum = 102;
}
}
Here the code gives me this when I type in 101: Are you sure you want to quit? Enter a number between 1 and 100:
*The code does not wait for
confirm = input.nextLine();
if (confirm == "yes") {
inum = 102;
}
step.