Answer to Question #4821 in Java | JSP | JSF for Nick

Question #4821
Java

Anyone know how to make a Switch statement to ask the user for a number and then convert it to a single Chinese character and print it out?



I just need a small example so I can get started. So far I got the unicode for Chinese characters.

4E8C = 1 in chinese
4E09 = 2
1
Expert's answer
2012-05-18T11:50:19-0400
import java.util.Scanner;

public class Test {

public static
void main(String[] args) {
Scanner in = new
Scanner(System.in);
String usersChoise = in.next();
char
result = ' ';
switch (usersChoise.charAt(0)) {
case
'1':
result = 0x4E8C;
break;
case
'2':
result = 0x4E09;
break;
}

System.out.println(Character.toString(result));
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS