public class Test2 {
public static void main(String[] args) throws Exception {
System.out.println("请输入一个数字:");
// 键盘录入数字
BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
System.out.println(toChinese(buf.readLine()));
buf.close();
}
//把数字转换成中文格式。
public static String toChinese(String str) {
String chinse = "零一二三四五六七八九";
StringBuilder buf = new StringBuilder(str.length());
for (int i = 0; i < str.length(); ++i) {
buf.append(chinse.charAt(str.charAt(i) - '0'));
}
return buf.toString();
}
} |
|