java输入月份判断季节
时间: 2023-12-07 07:05:16 浏览: 92
好的,以下是 Java 判断季节的代码:
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("请输入月份:");
int month = scanner.nextInt();
String season;
switch (month) {
case 12:
case 1:
case 2:
season = "冬季";
break;
case 3:
case 4:
case 5:
season = "春季";
break;
case 6:
case 7:
case 8:
season = "夏季";
break;
case 9:
case 10:
case 11:
season = "秋季";
break;
default:
season = "输入月份有误!";
}
System.out.println("该月份属于" + season);
}
}
```
阅读全文