package ch7;
import java.io.*;
public class ch7_10_2
{
public static void main(String awgs[]) throws IOException
{
InputStreamReader in=new InputStreamReader(System.in);
BufferedReader buf=new BufferedReader(in);
String n[]= {"零","壹","貳","參","肆","伍","陸","柒","哵","玖"};
String sn;
int num=4321,a,b,c,d=1;
System.out.println("請輸入九位以下數字");
sn=buf.readLine();
num=Integer.parseInt(sn);
b=100000000;
sn="";
c=num;
a=c;
do
{
a=num;
c=a%b;
num=c;
a=(a-c)/b;
if(a==0)
{
if(d==0)
{
sn=sn.concat(n[0]);
d++;
}
}
else
{
d=0;
}
if (d==0)
{
sn=sn.concat(n[a]);
switch (b)
{
case 0:
break;
case 10:
sn=sn.concat("拾");
break;
case 100:
sn=sn.concat("佰");
break;
case 1000:
sn=sn.concat("仟");
break;
case 10000:
sn=sn.concat("萬");
break;
case 100000:
sn=sn.concat("拾");
break;
case 1000000:
sn=sn.concat("佰");
break;
case 10000000:
sn=sn.concat("仟");
break;
case 100000000:
sn=sn.concat("億");
break;
}
}
else
{
if(b==10000)
{
sn=sn.concat("萬");
}
}
b=b/10;
}while(b!=0);
System.out.print("金額是"+sn);
}
}
===============
請輸入九位以下數字
987654321
金額是玖億哵仟柒佰陸拾伍萬肆仟參佰貳拾壹
留言列表