首页 > 其他 > 详细

人民币

时间:2015-01-07 21:52:43      阅读:139      评论:0      收藏:0      [点我收藏+]

人民币转换

 1 package t0107;
 2 
 3 public class Money {
 4 
 5     private static final char[] data = new char[]{
 6         ‘零‘,‘壹‘,‘贰‘,‘叁‘,‘肆‘,‘伍‘,‘陆‘,‘柒‘,‘捌‘,‘玖‘,
 7     };
 8     private static char[] units = new char[]{
 9         ‘元‘,‘拾‘,‘佰‘,‘仟‘,‘万‘,‘拾‘,‘佰‘,‘仟‘,‘亿‘,
10     };
11     /**
12      * @param args
13      */
14     public static void main(String[] args) {
15         System.out.println( convert(12123313) );
16 
17     }
18     
19     public static String convert(int money){
20         StringBuffer sbf = new StringBuffer();
21         int unit = 0;
22         while(money != 0){
23             
24             sbf.insert(0, units[unit++]);
25             int number = money%10;
26             sbf.insert(0, data[number]);
27             money /= 10;
28         }
29         return sbf.toString();
30     }
31 
32 }

 

人民币

原文:http://www.cnblogs.com/cfb513142804/p/4209415.html

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