zoukankan      html  css  js  c++  java
  • java切割~~百万 十万 万 千 百 十 个 角 分

     /**
         * @param value
         * @return
         */
        @SuppressWarnings("unused")
        public static void convertLoanRMBTable(double value) {
            LoanContractTemplateBean.LoanRMBTable loanRMBTable = new LoanContractTemplateBean.LoanRMBTable();
                    //百万          十万            万                千            百                十            个              角                分
            String million = "",lakh= "",tenThousand= "",thousand="",hundred= "",ten= "",one="",dime= "",cent= "";
            long midVal = (long) (((value+0.000001) * 1000) / 10); //转化成整形
            String valStr = String.valueOf(midVal); //转化成字符串
            //确保字符串长度大于等于2
            if (valStr.length() == 1) {
                valStr = "0" + valStr;
            }
            String head = valStr.substring(0, valStr.length() - 2);//取整数部分
            String rail = valStr.substring(valStr.length() - 2);//取小数部分
            int headLen = head.length();
            dime=rail.charAt(0) + "";
            cent=rail.charAt(1) + "";
            //9000000
            if (headLen < 7) {
                head = "¥" + head;
                int headLen2 = head.length();
                if (headLen2 < 7) {
                    String added = "";
                    for (int i = 0; i < 7 - headLen2; i++) {
                        added += "a";
                    }
                    head = added + head;
                }
                million= head.charAt(0) == 'a' ? "" : head.charAt(0) + "";
                lakh=head.charAt(1) == 'a' ? "" : head.charAt(1) + "";
                tenThousand=head.charAt(2) == 'a' ? "" : head.charAt(2) + "";
                thousand=head.charAt(3) == 'a' ? "" : head.charAt(3) + "";
                hundred=head.charAt(4) == 'a' ? "" : head.charAt(4) + "";
                ten=head.charAt(5) == 'a' ? "" : head.charAt(5) + "";
                one=head.charAt(6) == 'a' ? "" : head.charAt(6) + "";
            } else if (headLen == 7) {
                million= "¥" + head.charAt(0);
                lakh=head.charAt(1) + "";
                tenThousand=head.charAt(2) + "";
                thousand=head.charAt(3) + "";
                hundred=head.charAt(4) + "";
                ten=head.charAt(5) + "";
                one=head.charAt(6) + "";
            }
            System.out.println("百万==="+million+"	十万==="+lakh+"	万==="+tenThousand+"	千==="+thousand+"	百==="+hundred+"	十==="+ten+"	个==="+one+"	角===="+dime+"	分===="+cent);
        }
        //测试
        public static void main(String[] args) {
            convertLoanRMBTable(3225658.25);
        }
  • 相关阅读:
    csp-s模拟 77/78 (达哥专场)
    csp-s 模拟76
    csp-s模拟75 导弹袭击
    反思集
    模拟69/70 考试反思
    抱大腿
    csp-s模拟61 甜圈
    实时记录
    好题思路集汇
    半集训反思 8.28 「路,还是要自己走的」
  • 原文地址:https://www.cnblogs.com/yy123/p/4244011.html
Copyright © 2011-2022 走看看