/*
1、根据指定月份,打印该月份所属的季节。
3,4,5 春季
6,7,8 夏季
9,10,11 秋季
12, 1, 2 冬季
if和switch各写一版
*/
/*
public class Test01{
public static void main(String[] args){
java.util.Scanner s = new java.util.Scanner(System.in);
System.out.print("请输入月份:");
int month = s.nextInt();
String str = "冬季";
//判断是否合法
if(month < 1 || month >12){
System.out.println("您的输入有误!");
return;
}
if(month >= 3 && month <=5 ){
str = "春季";
}else if(month >= 6 && month <=8 ){
str = "夏季";
}else if(month >= 9 && month <=11 ){
str = "秋季";
}
System.out.println("当前季节为:" + str);
}
}
*/
public class Test01
根据指定月份,打印该月份所属的季节。 3,4,5 春季 6,7,8 夏季 9,10,11 秋季 12, 1, 2 冬季 if和switch各写一版
最新推荐文章于 2023-06-09 12:13:29 发布