Create a menudriven program that converts a character betwee
Solution
MenuTest.java
import java.util.Scanner;
public class MenuTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while(true){
System.out.println(\"a. Convert Character to Unicode\ b. Convert to Unicode to Character\ c. Exit\ \");
System.out.println(\"Enter your choice: \");
char ch = scan.next().charAt(0);
switch(ch){
case \'a\':System.out.println(\"Enter the character: \");char c = scan.next().charAt(0);
System.out.println(\"Unicode is \"+(int)c);break;
case \'b\':System.out.println(\"Enter the Unicode: \");int i = scan.nextInt();
System.out.println(\"Character is \"+(char)i);break;
case \'c\': System.exit(0);
default: System.out.println(\"Invalid choice.\");
}
}
}
}
Output:
a. Convert Character to Unicode
b. Convert to Unicode to Character
c. Exit
Enter your choice:
a
Enter the character:
b
Unicode is 98
a. Convert Character to Unicode
b. Convert to Unicode to Character
c. Exit
Enter your choice:
b
Enter the Unicode:
98
Character is b
a. Convert Character to Unicode
b. Convert to Unicode to Character
c. Exit
Enter your choice:
c
