Dear Expert:
Below I have included a simple DO WHILE loop. Occasionally when I try to exit the loop it says batch file missing and re-enters the loop. I have the code from the main method as well as the output when the error occurs.
import corejava.*; //This is for the Console.read
class cyrptograph
{
public static void main (
String args[])
{
char quit;
do
{
System.out.println ("Enter 1 to encode a message");
System.out.println ("Enter 2 to decode a message");
int resp = Console.readInt ("enter choice:");
if ( resp == 1)
encode();
else
decode();
String response = Console.readLine ("Enter C to continue or Q to quit");
quit = response.charAt(0);
} while (quit == 'C' | | quit == 'c');
System.out.println ("Goodbye");
} //end of main
This problem only happens periodically, but here is output I get when it happens:
Enter C to continue or Q to quit q
Goodbye
Batch file missing
C:\JavaPro\Practice\DosApp\Cryptography>
Enter 1 to encode a message
Enter 2 to decode a message
enter choice:
You can see how it prints "Goodbye" which means it has exited the DO WHILE loop, yet it somehow ends up back in the loop. Does anyone know why?