| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1074 人关注过本帖
标题:求教:Java中将100以内的数字翻译成英文,但是我的程序为什么输入1 2按回车 ...
只看楼主 加入收藏
紫诺
Rank: 1
来 自:中国
等 级:新手上路
帖 子:8
专家分:0
注 册:2019-11-3
结帖率:0
收藏
 问题点数:0 回复次数:0 
求教:Java中将100以内的数字翻译成英文,但是我的程序为什么输入1 2按回车键没有输出呢?
package ch02;
import java.util.Scanner;

public class L {
    public static void main(String[] args) {
        int x[] = { 0, 1};
        int y[]={ 2, 3, 4, 5, 6, 7, 8, 9 };
        int h[]={1,2,3,4,5,6,7,8,9};
        String z[] = { "zero", "one", "two", "three", "four", "five", "six",
                "eight", "nine" };
        String w[] = {"ten", "eleven", "twelve", "thirteen", "fourteen",
                "fifteen", "sixteen", "seventeen", "eighteen", "nineteen" };
        String t[] = {"twenty", "thirty", "fourty", "fifty", "sixty",
                "seventy", "eighty", "ninty" };
        Scanner sin=new Scanner(System.in);
        System.out.println("请输入数字");
        int m=sin.nextInt();
        int num[]=new int[m];
        for(int i=0;i<3;i++){
            num[i]=sin.nextInt();
        }
        for(int j=0;j<3;j++)
        {
        if(num[0]==1)
            {
                for(int i=0;i<10;i++)
                {
                    if(num[1]==x[i])
                    {
                        System.out.println(w[i]);
                    }
                }
            }
            else if(num[0]==0)
            {
                for(int i=0;i<10;i++)
                {
                    if(num[1]==x[i])
                    {
                        System.out.println(z[i]);
                    }
                }
            }
            else
            {
                for(int i=0;i<10;i++)
                {
                    if(num[0]==y[i])
                    {
                        for(int a=0;a<10;a++)
                        {
                            if(num[1]==h[a])
                            {
                                System.out.println(t[i]+"-"+z[i+1]);
                            }
                            else if(num[1]==0)
                            {
                                System.out.println(t[a]);
                            }
                        }
                    }
                }
               
            }
        }
        
        sin.close();
    }
}
搜索更多相关主题的帖子: int for System num println 
2020-03-08 20:45
快速回复:求教:Java中将100以内的数字翻译成英文,但是我的程序为什么输入1 2按 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.033258 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved