-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadNumInChinese
56 lines (43 loc) · 1.05 KB
/
readNumInChinese
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package homework;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int input = in.nextInt();
int n = input;
String output = "";
int digit = 0;
if (n < 0) {
n = -n;
}
if (n == 0)
digit = 1;
else {
int m = n;
while (m > 0) {
m /= 10;
digit++;
}
}
for (int i = 0; i < digit; i++) {
switch (n % 10) {
case 0 : output = "ling " + output; break;
case 1 : output = "yi " + output; break;
case 2 : output = "er " + output; break;
case 3 : output = "san " + output; break;
case 4 : output = "si " + output; break;
case 5 : output = "wu " + output; break;
case 6 : output = "liu " + output; break;
case 7 : output = "qi " + output; break;
case 8 : output = "ba " + output; break;
case 9 : output = "jiu " + output; break;
}
n = (n - n % 10 ) / 10;
}
if (input < 0) {
output = "fu " + output;
}
output = output.substring(0, output.length()-1);
System.out.println(output);
}
}