Westonci.ca is the ultimate Q&A platform, offering detailed and reliable answers from a knowledgeable community. Get detailed and accurate answers to your questions from a community of experts on our comprehensive Q&A platform. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
Sagot :
Answer:
import java.util.Scanner;
import java.lang.*;
class Main {
public static void main(String[] args) {
boolean exit = false;
Scanner reader = new Scanner(System.in);
while(!exit) {
char c = '?';
while( !Character.isLetter(c)) {
System.out.print("Enter a letter or * to exit: ");
c = reader.next().charAt(0);
if (c == '*') {
exit = true;
break;
}
if (!Character.isLetter(c)) {
System.out.printf("Error: %c is not a letter!\n", c);
}
}
if (Character.isLowerCase(c)) {
System.out.printf("%c in uppercase is %c\n", c, Character.toUpperCase(c));
} else if (Character.isUpperCase(c)) {
System.out.printf("%c in lowercase is %c\n", c, Character.toLowerCase(c));
}
}
reader.close();
}
}
Explanation:
I decided to use the asterisk (*) as exit character.
Thanks for using our service. We're always here to provide accurate and up-to-date answers to all your queries. Thank you for visiting. Our goal is to provide the most accurate answers for all your informational needs. Come back soon. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.