/**
* Hw1
*
* @author Linguiyi
* @version 1.0
* @date 2023/7/11 17:31
*/
public class Hw1 {
public static void main(String[] args) {
//seasonWithIf(4);
seasonWithSwitch(3);
}
public static void seasonWithIf (int month){
if(month < 1 || month >12){
System.out.println("您的输入有误!");
}
if(month == 3||month == 4 || month == 5){
System.out.println("春季");
}
if(month == 6||month == 7 || month == 8){
System.out.println("夏季");
}
if(month == 9||month == 10 || month == 11){
System.out.println("秋季");
}
if(month == 12||month == 1 || month == 2){
System.out.println("冬季");
}
}
public static void seasonWithSwitch (int month){
if(month < 1 || month >12){
System.out.println("您的输入有误!");
}
switch (month){
case 3:
case 4:
根据指定月份,打印该月份所属的季节。3,4,5 春季 6,7,8 夏季 9,10,11 秋季 12, 1, 2 冬季 if和switch各写一版
最新推荐文章于 2024-12-03 12:58:34 发布

最低0.47元/天 解锁文章
4389





