//导包
import java.util.Scanner;
puiblic class SwitchDemo {
public static void main(String[] args) {
//创建对象
Scanner b = new Scanner(System.in);
System.out.println("请输入月份数字(1~12):");
int month = b.nextInt();
switch (month) {
case 1:
case 2:
case 12:
System.out.println("冬季");
break;
case 3:
case 4:
case 5:
System.out.println("春季");
break;
case 6:
case 7:
case 8:
System.out.println("夏季");
break;
case 9:
case 10:
case 11:
System.out.println("秋季");
break;
default:
System.out.println("您输入的月份有误!");
}
}
}
switch分支结构案例.01
最新推荐文章于 2023-11-23 20:33:39 发布