简单代码实现100内阿拉伯数字转英文

import java.util.*;
public class test{
public static void main(String[] args) {
Scanner shuzi=new Scanner(System.in);
    
System.out.println("使用请输入\"1\"+回车,退出按任意键+回车");
int pd=shuzi.nextInt();
    
while (pd==1) {
System.out.println("请输入一个100以内的数字:");
int begin=shuzi.nextInt();

    
if(begin>19) {
int gw=begin%10;
int sw=begin/10%10;
System.out.println("当前数字是:"+begin+"\n"+"十位是:"+sw+"\n"+"个位是:"+gw);
String[]ten=new String[] {"","ten","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninty"};
String[]one=new String[] {"","-one","-two","-three","-four","-five","-six","-seven","-eight","-nine"};
System.out.println("你输入的数字:"+begin+"的英文是:"+ten[sw]+one[gw]);
    }    
    
    
if(begin>9&begin<20) {
int gw=begin%10;
System.out.println("当前数字是:"+begin+"\n"+"个位是:"+gw);
String[]shi=new String[] {"ten","eleven","twevle","thirteen","fourteen","fifteen","sixteen","seventeen","eightieen","nineteen"};
System.out.println("你输入的数字:"+begin+"的英文是:"+shi[gw]);
    }
    
    
if(begin>1&begin<10) {
int gw=begin%10;
System.out.println("当前数字是:"+begin+"\n"+"个位是:"+gw);
String[]ge=new String[] {"two","three","four","five","six","seven","eight","nine"};
System.out.println("你输入的数字:"+begin+"的英文是:"+ge[gw-2]);    
    }
    
System.out.println("使用请输入\"1\"+回车,退出按任意键+回车");
int pd2=shuzi.nextInt();
if(pd2!=1) {
        break;
    }
    }
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值