One of the requirements of my project is that the program loops until the user presses the "X" key. I have the method for this, but the program terminates even when the method is not called. Here is my code:
while (terminate == false)
{
    // Ask user for input
    switch (command)
    {
        case "I":
        {
            // Do stuff
        }
        case "X":
        {
            terminateProgram();
        }
    }
}
This is my terminate method:
private static boolean terminateProgram()
{
    terminate = true;
    return terminate;
}
Even if I enter the "I" key, the loop ends after the case for "I" is completed. "I" works normally if terminateProgram(); is commented. How do I get the loop to stop only when I enter "X"?
 
     
    