首页 > 代码库 > 大写数字转换
大写数字转换
package data;public class NumCover{ private String[] numArry = {"零", "壹","贰","叁","肆","伍","陆","柒","捌","玖"}; private String[] unitArry = {"拾", "佰","仟","万","十万","百万","千万","亿","十亿","百亿","千亿"}; public String[] div(double num){ long zheng = (long)num; long xiao = Math.round((num - zheng) * 100); return new String[]{String.valueOf(zheng),String.valueOf(xiao)}; } public String cover(String numStr){ String result = ""; int len = numStr.length(); for(int i = 0;i<len; i++){ int num = numStr.charAt(len-1-i)-48; int prenum = 0; boolean b = false; if(i != len-1){ prenum = numStr.charAt(len-2-i)-48; } if(i!= 0 && num != 0){ result = numArry[num] + unitArry[i-1] +result; b = true; } else if((prenum != 0 && b) || ((i == 0) && (num !=0))) { result = numArry[num] + result; } } return result; }}
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。