用Java完成 输入一个月份,输出属于哪个季节 用循环完成
时间: 2023-06-04 11:07:03 浏览: 91
好的,这个问题可以回答。以下是Java代码:
```
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("请输入月份:");
int month = sc.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);
}
}
```
阅读全文