根据月份,判断季节的Java代码
时间: 2023-04-06 12:04:29 浏览: 353
java代码-季节与月份
以下是一个简单的根据月份判断季节的Java代码:
```
import java.util.Scanner;
public class Season {
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 = "输入错误";
break;
}
System.out.println("这个月份是" + season);
}
}
```
阅读全文