當前位置:成語大全網 - 新華字典 - 提供壹個JAVA程序,就是輸入阿拉伯數字運行讓他變成大寫的漢字,比如:123變成壹貳三之類

提供壹個JAVA程序,就是輸入阿拉伯數字運行讓他變成大寫的漢字,比如:123變成壹貳三之類

import java.io.*;

public class Test1 {

/**

* @param args

*/

public static void main(String[] args) {

//數據字典!

char c[]={'零','壹','貳','三','肆','伍','陸','柒','捌','玖'};

//等待輸入!

System.out.print("請輸入壹個阿拉伯數字: ");

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

//得到輸入!

try {

String input=br.readLine();

for(int count=0;count<input.length();count++){

//轉成數字

char temp=input.charAt(count);

switch (temp){

case '1':System.out.print(c[1]);break;case '2':System.out.print(c[2]);break;

case '3':System.out.print(c[3]);break;case '4':System.out.print(c[4]);break;

case '5':System.out.print(c[5]);break;case '6':System.out.print(c[6]);break;

case '9':System.out.print(c[9]);break;case '8':System.out.print(c[8]);break;

case '0':System.out.print(c[0]);break;default:break;

}

}

} catch (IOException e) {

e.printStackTrace();

}

}

}