import java.util.Scanner;
public class SwitchScannerTest {
public static void main(String[] args) {
//switch语句 + Scanner测试
@SuppressWarnings("resource")
Scanner scanner = new Scanner(System.in);
System.out.println("Please enter a data(1~7):");
int weekday = scanner.nextInt();
switch (weekday)
{
case 1:
System.out.print("星期一"); break;
case 2:
System.out.print("星期二"); break;
case 3:
System.out.print("星期三"); break;
case 4:
System.out.print("星期四"); break;
case 5:
System.out.print("星期五"); break;
case 6:
System.out.print("星期六"); break;
case 7:
System.out.print("星期日"); break;
default:
System.out.print("输入错误!"); break;
}
}
}
JAVA My first Switch
最新推荐文章于 2024-09-17 09:00:00 发布