首页 > 其他 > 详细

人民币转换大写

时间:2017-02-23 18:22:55      阅读:260      评论:0      收藏:0      [点我收藏+]

1、

public class RenMinBi {
    //数字
    private static final char[] data = new char[] {‘零‘, ‘壹‘, ‘贰‘, ‘叁‘, ‘肆‘,
        ‘伍‘, ‘陆‘, ‘柒‘, ‘捌‘, ‘玖‘};
    //单位
    private static final char[] units = new char[] {‘元‘, ‘拾‘, ‘佰‘, ‘仟‘, ‘万‘,
        ‘拾‘, ‘佰‘, ‘仟‘, ‘亿‘};
     static int count = 0;
    
    public String change(String str) {
        StringBuffer sb = new StringBuffer();
        String moneystr = str.substring(1);
        Integer money = Integer.parseInt(moneystr);
        while (money!=0) {
            int yushu = money%10;
            sb.insert(0,units[count++]);
            sb.insert(0, data[yushu]);
            money = money/10;
        }
        return sb.toString();
    }
}

 

人民币转换大写

原文:http://www.cnblogs.com/h-g-f-s123/p/6434646.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!