Answer:
import java.util.Scanner;
public class num6 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Enter an alphabet");
char origLetter = in.next().charAt(0);
String greekLeter ="";
switch (origLetter){
case 'A' :
greekLeter="Alpha";
break;
case 'a':
greekLeter="Alpha";
break;
case 'B':
greekLeter= "Beta";
break;
case 'b':
greekLeter = "Beta";
default:
greekLeter="Unknown";
}
System.out.println("You entered the letter "+origLetter+" The greek letter is" +
" "+greekLeter);
}
}
Step-by-step explanation:
- A complete Java program is given above
- Using a the Scanner class, the user is prompted for a character which is received and stored in the variable origLetter
- The switch statement implements four cases, case of A, a, B and b to handle lower and upper case characters and assigns the appropriate String to the variable greekLeter as specified by the question
- Finally the letter entered and the greekLeter is printed out.