要求:(1)定义一个整数(代表月份,范围1-12)
(2)输出该月份对应的季节
3,4,5春季
6,7,8夏季
9,10,11秋季
12,1,2冬季
(3)演示格式如下:
月份:3
控制台输出:3月份是春季
`public class Test06{
public static void main(String[] args) {
int month=3;
boolean spring=month>=3 && month<=5;
boolean summer=month>=6 && month<=8;
boolean autumn=month>=9 && month<=11;
boolean hibernate=month>=1 && month<=2 || month==12;
boolean out=month>12 || month<1;
System.out.print(spring!=true?"":month+"月份春季");
System.out.print(summer!=true?"":month+"月份夏季");
System.out.print(autumn!=true?"":month+"月份秋季");
System.out.print(hibernate!=true?"":month+"月份冬季");
System.out.print(out!=true?"":"月份范围错误");
}
}`