-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJudgeMonth.java
More file actions
36 lines (34 loc) · 1.05 KB
/
Copy pathJudgeMonth.java
File metadata and controls
36 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.mingrisoft;
import java.util.Scanner;
public class JudgeMonth {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in); // 创建扫描器
// 提示用户输入月份
System.out.println("请输入一个月份,我能告诉你它属于哪个季节。");
int month = scan.nextInt(); // 接收用户输入
switch (month) { // 判断月份属于哪个季节
case 12:
case 1:
case 2:
System.out.print("您输入的月份属于冬季。");
break;
case 3:
case 4:
case 5:
System.out.print("您输入的月份属于春季");
break;
case 6:
case 7:
case 8:
System.out.print("您输入的月份属于夏季");
break;
case 9:
case 10:
case 11:
System.out.print("您输入的月份属于秋季");
break;
default:
System.out.print("你那有" + month + "月份吗?");
}
}
}