1 package com.demo;
2
3 import java.util.Scanner;
4
5 /*
6 * 题目:根据指定月份,打印该月份所属的季节
7 *
8 * 春季:3 4 5
9 * 夏季:6 7 8
10 * 秋季:9 10 11
11 * 冬季:12 1 2
12 */
13
14 public class Season {
15 public static void main(String[] args) {
16
17 Scanner input = new Scanner(System.in);
18
19 System.out.print("请输入月份(1-12):");
20 int month = input.nextInt();
21
22 switch (month) {
23 case 3:
24 case 4:
25 case 5:
26 System.out.println("春季");
27 break;
28 case 6:
29 case 7:
30 case 8:
31 System.out.println("夏季");
32 break;
33 case 9:
34 case 10:
35 case 11:
36 System.out.println("秋季");
37 break;
38 case 12:
39 case 1:
40 case 2:
41 System.out.println("冬季");
42 break;
43 default:
44 System.out.println("输入有误");
45 break;
46 }
47
48 }
49 }