100以内阿拉伯数字转化为汉字.

今天在面试中遇到这样的题.麻烦哪位大神能帮吗解决一下!跪谢了
在函数execute中完成下面的功能: 参数amout是一个大于0的整数,最大值为99,类似:45
在函数中需要将amount转化为中文的描述,类似:四十五(按照日常惯例,例如14需要转化为“十四”,而不是“一十四”)
数字大写说明:一,二,三,四,五,六,七,八,九,十

public class Test {

public static void main(String[] args) {
    int amout = 11;
    int amout2 = 20;
    int amout3 = 66;
    System.out.println(amout+":"+execute(amout));
    System.out.println(amout2+":"+execute(amout2));
    System.out.println(amout3+":"+execute(amout3));
}

public static String execute(int amout){
    String str ="";
    if(amout<0||amout>99){
        str="不合法的数字";
    }else if(amout>=1&&amout<=10){
        str = cast(amout);
    }else if(amout>=11&&amout<=19){
        int num = amout%10;
        str = "十"+cast(num);
    }else if(amout>=20&&amout<=99){
        int num1 = amout/10%10;
        int num2 = amout%10;
            str = cast(num1)+"十"+cast(num2);
    }

    return str;

}

public static String cast(int num){
    String str="";
    switch(num){
    case 0:
        str="";
        break;
    case 1:
        str="一";
        break;
    case 2:
        str="二";
        break;
    case 3:
        str="三";
        break;
    case 4:
        str="四";
        break;
    case 5:
        str="五";
        break;
    case 6:
        str="六";
        break;
    case 7:
        str="七";
        break;
    case 8:
        str="八";
        break;
    case 9:
        str="九";
        break;
    case 10:
        str="十";
        break;
    }
    return str;

}

}

程序运行结果:

11:十一

20:二十

66:六十六

分类看看:
1、定义一个字符串数组,a[十,一,二,三,四,五,六,七,八,九],这里简写,即:索引为0对应十,1对应一,以此类推。
2、对1~99分成三类(1~10,11~19,20~99)。
3、参数amout属于1~10,return a[amount%10];
4、参数amout属于11~19,return a[0]+a[amount%10];
5、参数amout属于20~99,return amount%10==0?a[amount/10]+a[amount%10]:a[amount/10]+a[0]+a[amount%10];

不会JAVA ,但是我觉得只要思路对,你用自己的编程语言写出来就可以了呀

 package 打印汉字;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        if (num < 10) {
            System.out.println(f(num));
        } else if (num < 20) {
             int g = num % 10; // 表示个位上的数字
            System.out.println("十" + f(g));
        } else if (num < 100) {
            int s = num / 10; // 表示十位上的数字
            int g = num % 10; // 表示个位上的数字
            System.out.println(f(s) + "十" + f(g));
        }
    }

    // 这里写一个函数,表示输入对应的数字输出汉字
    public static String f(int num) {
        String answer = "";
        if (num == 1) {
            answer = "一";
        }
        if (num == 2) {
            answer = "二";
        }
        if (num == 3) {
            answer = "三";
        }
        if (num == 4) {
            answer = "四";
        }
        if (num == 5) {
            answer = "五";
        }
        if (num == 6) {
            answer = "六";
        }
        if (num == 7) {
            answer = "七";
        }

        if (num == 8) {
            answer = "八";
        }
        if (num == 9) {
            answer = "九";
        }

        return answer;

    }

}

函数名什么的相应的改改就好了,不需要用到数组尽量不用