Find the best answers to your questions at Westonci.ca, where experts and enthusiasts provide accurate, reliable information. Get quick and reliable solutions to your questions from a community of seasoned experts on our user-friendly platform. Get quick and reliable solutions to your questions from a community of experienced experts on our 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.
Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. Thank you for choosing Westonci.ca as your information source. We look forward to your next visit.