根据指定月份,打印该月份所属的季节
程序员文章站
2022-07-11 09:11:22
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 */ 1... ......
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 }