本文主要是介绍1234567转成一百二十三万四千五百六十七,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
public class Test {static String[] units = { "", "十", "百", "千", "万", "十万", "百万", "千万", "亿", "十亿", "百亿", "千亿", "万亿" };
static char[] numArray = { '零', '一', '二', '三', '四', '五', '六', '七', '八', '九' };
public static void main(String[] args) {
int num = 1234132;
StringBuilder sb = new StringBuilder();
char [] var = String.valueOf(num).toCharArray();
for(int i=0; i<var.length; i++){
int cc = Integer.valueOf(String.valueOf(var[i]));
char bb = numArray[cc];
String aa = units[var.length-i-1];
if("十万".equals(aa)){
aa = "十";
}
if("百万".equals(aa)){
aa = "百";
}
if("千万".equals(aa)){
aa = "千";
}
sb.append(bb+aa);
}
System.out.print(sb);
}
}
这篇关于1234567转成一百二十三万四千五百六十七的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!