- class RenMingBi {
- private static final char[] data = new char[] { '零', '壹', '贰', '叁', '肆',
- '伍', '陆', '柒', '捌', '玖' };
- private static final char[] units = new char[] { '元', '拾', '佰', '仟', '万',
- '拾', '佰', '仟', '亿' };
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- System.out.println(convert(1300023));
- }
- public static String convert(int money) {
- StringBuffer sbf = new StringBuffer();
- int unit = 0;
- int before = -1;
- while (money != 0) {
- int number = money % 10;
- if(number == 0 && before != 0) {
- sbf.insert(0, data[number]);
- before = 0;
- } else if(number == 0 && before == 0) {
- before = 0;
- } else {
- sbf.insert(0, units[unit++]);
- sbf.insert(0, data[number]);
- before = -1;
- }
- money /= 10;
- }
- return sbf.toString();
- }
- }