I have written code that changes uppercase letters to lowercase letters and vice versa. I'm trying to use break
so that I can exit the loop whenever the input is '.'
, and it doesn't seem to be working. Any advice would be appreciated! I also want to create a count of all the time the loops reiterated before it ended. How would I go about that?
public static void main(String[] args) throws java.io.IOException {
char choice, ignore = 0;
for (; ; ) {
do {
System.out.print("Please enter a upper or " + "lower case letter(. to quit)");
choice = (char) System.in.read();
if ((char) choice > 64) {
ignore = (char) (choice + 32);
}
if ((char) choice > 96) {
ignore = (char) (choice - 32);
}
System.out.print(ignore);
System.out.println("\n");
if (choice == '.') {
break;
}
do {
ignore = (char) System.in.read();
} while (ignore != '\n');
} while ((char) choice > 64 | (char) choice < 123 | choice != '.');
}
}