阿拉伯数字转中国的数字
import java.util.*;
class Work7
{
public static void main(String[] args)
{
System.out.println("请输入一个数字");
String[] str = new String[]{"拾","百","千","万","十","百","千","亿","十","百","千"};
Scanner sac = new Scanner(System.in);
int sum = sac.nextInt();
int sum2=sum;
int a=0;
for (int i = 0 ; i<32 ;i++ )
{
if(sum/10>0){
sum=sum/10;
a++;
}else{
break;
}
}
if (sum2<10)
{
int k =sum;
String ss = zifu(k);
System.out.print(ss+"元整");
}else{
for (int i = a ;i>=0 ;i-- )
{
if (i==0)
{
int c = sum2%10;
String ss1 = zifu(c);
System.out.print(ss1+"元整");
}else if(i>0){
int new1=(int)Math.pow( 10, i);
//参数说明:m为要求方的数,n为次方数
int b = sum2/new1%10;
String ss2 = zifu(b);
if (b==0)
{
//System.out.print(a+""+i);
if (i==4||i==8)
{
if (i==8)
{
System.out.print("亿"+ss2);
}else{
System.out.print("万"+ss2);
}
}
else{
System.out.print(ss2);
}
}else{
System.out.print(ss2+""+str[i-1]);
}
}
}
}
}
public static String zifu(int a){
String str =" ";
switch (a)
{
case 1:
str ="一";
break;
case 2:
str ="二";
break;
case 3:
str ="三";
break;
case 4:
str ="四";
break;
case 5:
str ="五";
break;
case 6:
str ="六";
break;
case 7:
str ="七";
break;
case 8:
str ="八";
break;
case 9:
str ="九";
break;
case 0:
str ="零";
break;
default :
break;
}
return str;
}
}