posts - 137,comments - 0,views - 40818
复制代码
import java.util.Scanner;
public class XMT_Ex2 {
    public static void main(String[] args){
        int month;
        while (true)
        {
            Scanner input = new Scanner(System.in);
            System.out.println("请输入一个月份:");
            month = input.nextInt();
            if (month > 0 && month <= 12) {
                break;
            }
            else {
                System.out.println("请重新输入一个大于0小于等于12的整数!");
            }
        }
        switch (month)
        {
            case 1:
            case 2:
            case 12:
                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;
        }
    }
}
复制代码

posted on   wshidaboss  阅读(447)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· 写一个简单的SQL生成工具
· Manus的开源复刻OpenManus初探
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示