int wmath1 = 1;
do {
if (wmath.equals(add)) {
System.out.print(5 + 5);
} else if (wmath.equals(sub)) {
System.out.println(6 - 2);
} else {
System.out.println("sorry but that not an option");
int wmath1 = 0;
}
} while (wmath1 < 1);
}
I'm trying to create a loop where if the user doesn't choose any of the given options then the loop will happen again so he can choose one of the given options without having to go through the program over again.
However, when I assign wmath = 1
first this should allow the loop to end if the else statement isn't run but it's giving me the error that wmath1
is being reused even though it should let you rename the variables.
The above code is just the do while loop part of the code. The scanner part name wmath is not given.