数字转大写(java)
数字转大写
public class bnum {
public bnum() {
}
static String []bigNum={"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
static String []wei={"元","拾","佰","仟","万"};
static String []swei={"角","分"};
static String getNUM(String str){
int t=Integer.parseInt(str);
return bigNum[t];
}
static String getdanwei(int t){
return wei[t];
}
public static void main(String[] args) {
String strbig=new String("");
float num=12345.78f;
String temp=String.valueOf(num);
int bi=temp.indexOf(".");
int si=temp.length()-(bi+1);
System.out.println(temp.length()+" "+bi+" "+si);
int j=bi;
for (int i =0; i<bi;i++) {
strbig+=getNUM(temp.substring(i,i+1));
strbig+=getdanwei(j-1);
j--;
}
temp=temp.substring(bi+1,temp.length());
for (int i = 0; i < si; i++) {
strbig+=getNUM(temp.substring(i,i+1));
strbig+=swei[i];
}
System.out.println(strbig);
}
}