设为首页 加入收藏

TOP

Java浮点数转人民币读法(二)
2018-03-18 16:21:38 】 浏览:420
Tags:Java 点数 人民币 读法
pStr="0"+tempStr;
                    }
                    countArr++;
                    resZheng=zheng2Han(countArr,tempStr)+" "+resZheng;
                }else{
                    if(countNum==4){
                          countArr++;
                          resZheng=zheng2Han(countArr,tempStr)+" "+resZheng;
                          countNum=0;
                          tempStr="";
                    }   
                }
          }
         
          //去掉开头的零
          if(resZheng.charAt(0)=='零'){
                resZheng=resZheng.substring(1,resZheng.length());
          }
         
          /*整数和小数的连接*/
          //表示整数部分为0
          if(resZheng.charAt(0)=='元'){
                resZheng="零"+resZheng;
          }
         
          result=resZheng+resXiao;
         
          return result;
    }
   
    /**
      * 每个4位的整数组转化为大写的数字
      * @param count 记录是第几个数组(1-3)
      * @param str 需要被转换的数组
      * @return 返回该数组人民币读法
      */
    private String zheng2Han(int count,String str){
         
          String result="";
          for(int j=0;j<4;j++){
                int tempNum=str.charAt(j)-48;
                if(tempNum!=0){
                    if(j!=3){
                          result+=hanArr[tempNum]+unitArr[j];
                    }else{
                          result+=hanArr[tempNum];
                    }
                }else{
                    if((j-1<0)||(str.charAt(j-1)-48!=0)){
                          result+=hanArr[tempNum];
                    }
                }
    &
首页 上一页 1 2 3 下一页 尾页 2/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇TensorFlow 基本用法示例 下一篇Spring IOC容器的基本应用

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目