如果将用户从控制台输入的
52531.12
转换输出  
伍万贰千伍佰叁拾壹元壹角贰分不求算法
只求解题思路  谢谢!

解决方案 »

  1.   

    准备2个数组
    String[] a = new String[]{"分","角","元".....};
    String[] b = new String[]{"十","百","千".....};
      

  2.   

    肯定要有个一个方法,去匹配阿拉伯数字和中文的壹...用switch.case做
    然后就是取每一位的数字和他的位数了  我觉得不用拿这个数去整除什么10000啊什么的  直接拿字符串做处理  比如第5位的就是“万”  
      

  3.   

    a[]={"壹","贰","叁"...."九"}
    b[]={"角","分","元"}
    c[]={"拾","百","千","万","百万","千万","亿"...}
    将你的数据转换成字符串,然后以.分成两部份。
      

  4.   


    import java.util.*;public class Change { /**
     * @param args
     */
    long e;
    int FirstDigit;
    int SecondDigit;
    int ThirdDigit;
    int FourthDigit;
    int FifthDigit;
    int Digit;
    public Change (long e){
    this.e = e;
    }
    public String GargeDigit(){
    String a5,a4,a3,a2,a1;
    Contain a = new Contain();
    if(e/100000>0)
    {   String g = "错误,数字必须小于十万";
    return g;
    }
    else if (e/10000>0) {
    FirstDigit = (int)e/10000;
    SecondDigit = (int)((e/1000)%10);
    ThirdDigit = (int)((e/100)%10);
    FourthDigit = (int) ((e/10)%10);
    FifthDigit = (int) ((e/1)%10);
    Digit = 5;
    if (FirstDigit != 0) a5 = String.valueOf(FirstDigit);
    else a5= "";
    if (SecondDigit != 0) a4 = String.valueOf(SecondDigit);
    else a4 = "";
    if (ThirdDigit != 0) a3 = String.valueOf(ThirdDigit);
    else a3 = "";
    if(FourthDigit != 0) a2 = String.valueOf(FourthDigit);
    else a2 = "";
    a1 = String.valueOf(FifthDigit);
    String result = a.map2.get(a5) + a.map1.get("1") + a.map2.get(a4) + a.map1.get("2") + a.map2.get(a3) + a.map1.get("3")+ a.map2.get(a2) + a.map1.get("4") + a.map2.get(a1);
    return result;
    }
    else return "a";
    /* else if (e/1000>0) {
    FirstDigit = 0;
    SecondDigit = (int)e/1000; 
    ThirdDigit = (int)(e/100)%10;
    FourthDigit = (int) ((e/10)%10);
    FifthDigit = (int) ((e/1)%10);
    Digit = 4;
    }
    else if (e/100>0) { 
    FirstDigit = 0;
    SecondDigit = 0;
    ThirdDigit =(int)e/100; 
    FourthDigit = (int) ((e/10)%10);
    FifthDigit = (int) ((e/1)%10);
    Digit =3;
    }
    else if (e/10>0) {
    FirstDigit = 0;
    SecondDigit = 0;
    ThirdDigit = 0;
    FourthDigit =(int)e/100; 
    FifthDigit = (int) ((e/1)%10);
    Digit =2;
    }
    else if (e>0) { 
    FirstDigit = 0;
    SecondDigit = 0;
    ThirdDigit = 0;
    FourthDigit = 0;
    FifthDigit = (int) ((e/1)%10); 
    Digit =1;
    }*/
    }
    public static void main(String[] args) {
    // TODO Auto-generated method stub
    Change a = new Change(75432);
    System.out.println(a.GargeDigit());
    System.out.println("Digit = " + a.Digit);
    System.out.println("FirstDigit = " + a.FirstDigit);
    System.out.println("SecondDigit = " + a.SecondDigit);
    System.out.println("ThirdDigit = " + a.ThirdDigit);
    System.out.println("FourthDigit = " + a.FourthDigit);
    System.out.println("FifthDigit = " + a.FifthDigit);


    }}
    class Contain{
    Map<String,String> map1 = new HashMap<String,String>();
    Map<String,String> map2 = new HashMap<String,String>();
    public Contain(){

    map1.put("1", "万");
    map1.put("2", "千");
    map1.put("3", "百");
    map1.put("4", "十");
    map1.put("", "");

    map2.put("1", "壹");
    map2.put("2", "貳");
    map2.put("3", "叁");
    map2.put("4", "肆");
    map2.put("5", "伍");
    map2.put("6", "陆");
    map2.put("7", "柒");
    map2.put("8", "捌");
    map2.put("9", "玖");
    map2.put("0", "");

    }

    }// 只能输入5位数
    // 第一个问题 当50000的时候 千百十也有输出
    // 第二个问题 当50001的时候 输出不对/*我自己写的 还有很多很多bug LZ跟我一起优化下好吗