public class Test_SwitchDemo { public static void main(String[] args) { Scanner input = new Scanner(System.in); System.out.println("请输入月份:"); int month = input.nextInt(); // switch 实现 switch (month) { case 12: case 1: case 2: System.out.println(month + "月是冬季"); break; case 3: case 4: case 5: System.out.println(month + "月是春季"); break; case 6: case 7: case 8: System.out.println(month + "月是夏季"); break; case 9: case 10: case 11: System.out.println(month + "月是秋季"); break; default: System.out.println("输入的月份有误"); break; } } }
学习switch语句(2)
最新推荐文章于 2024-07-10 22:11:08 发布