Condition choice2 != 5 || choice2 != 6 choice2 != 5 || choice2 != 6 always true because there is no number equal to 5 and 6 at the same time.
If you want to exit the loop when 5 or 6 is entered, use && instead:
while (choice2 != 5 && choice2 != 6)
Make sure choice2 set before continuing the next iteration of the loop.
Note that you can exit the loop from your switch with the marked break construct:
calc: // Label the loop for using labeled break while (true) { ... switch(...) { case 1: break; // This will exit the switch ... case 6: break calc; // This will exit the loop } }
source share