• 数字转大写(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);
        }
    }

  • 相关阅读:
    ES2017中的修饰器Decorator
    ES6中的模块
    代理(Proxy)和反射(Reflection)
    ES2017中的async函数
    ES6数字扩展
    Promise和异步编程
    ES6定型数组
    ES6数组扩展
    ES6中的类
    ES6中的Set和Map集合
  • 原文地址:https://www.cnblogs.com/ahuo/p/611534.html
Copyright © 2020-2023  润新知