新手Java求教
发布网友
发布时间:2023-09-26 15:10
我来回答
共4个回答
热心网友
时间:2024-11-26 05:42
public static void main(String[] args) {
System.out.print("请输入一个整型数(0~10):");
Scanner scanner = new Scanner(System.in);
int i = scanner.nextInt();
switch (i) {
case 0:
System.out.println("零");
break;
case 1:
System.out.println("壹");
break;
case 2:
System.out.println("贰");
break;
case 3:
System.out.println("叁");
break;
case 4:
System.out.println("肆");
break;
case 5:
System.out.println("伍");
break;
case 6:
System.out.println("陆");
break;
case 7:
System.out.println("柒");
break;
case 8:
System.out.println("捌");
break;
case 9:
System.out.println("玖");
break;
case 10:
System.out.println("拾");
break;
default:
System.out.println("输入错误,无法判断,请重试!");
}
}
热心网友
时间:2024-11-26 05:43
我只写部分给你
int n;
switch(n) {
case 1:
System.out.println("零");
break;
........
}
你把case复制,像我这样写,一直写到十,之后你输入n是多少,就输出对应的汉语数字追问
再问一下啊,我输入case1时,提示出错,这是怎么个情况
热心网友
时间:2024-11-26 05:43
import java.util.Scanner;
public class Tes {
public static void main(String[] args) {
System.out.print("请输入一个整型数(0~10): ");
Scanner scan = new Scanner(System.in);
int i = scan.nextInt();
switch (i)
{
case 0:
System.out.println("零");
break;
case 1:
System.out.println("壹");
break;
case 2:
System.out.println("贰");
break;
case 3:
System.out.println("叁");
break;
case 4:
System.out.println("肆");
break;
case 5:
System.out.println("伍");
break;
case 6:
System.out.println("陆");
break;
case 7:
System.out.println("柒");
break;
case 8:
System.out.println("捌");
break;
case 9:
System.out.println("玖");
break;
case 10:
System.out.println("拾");
break;
default:
System.out.println("唉,无聊,我在练习编程写程序!");
}
}
}
热心网友
时间:2024-11-26 05:44
怎么看不到你的问题啊?