public class MonthAtSeason {
public static void main(String[] args) {
int month=4; // 声明月份变量
switch (month) {
case 12:
case 1:
case 2:
System.out.println(month+"月份是冬季");
break;
case 3:
case 4:
case 5:
System.out.println(month+"月份是春季");
break;
case 6:
case 7:
case 8:
System.out.println(month+"月份是夏季");
break;
case 9:
case 10:
case 11:
System.out.println(month+"月份是秋季");
break;
default:
System.out.println(month+"不是合法的月份数值");
break;
}
}
}
你输入的是一个季节,对应的是3个月份,怎么判断.
大哥,题目反了吧,不应该是输入月份,判断季节吗?