.NET程序设计——语言基础02

一、任务

编写一个控制台应用程序,可根据输入的月份判断所在季节

 

二、代码

static void Month()
        {
            int month;
            Console.WriteLine("***********季节判定系统**********");
            Console.WriteLine("请输入月份:(如“1”)");
            month = int.Parse(Console.ReadLine());
            if (month == 1 || month == 2 || month == 3)
            {
                Console.WriteLine(month + "月份为春季");
            }
            else if (month == 4 || month == 5 || month == 6)
            {
                Console.WriteLine(month + "月份为夏季");
            }
            else if (month == 7 || month == 8 || month == 9)
            {
                Console.WriteLine(month + "月份为秋季");
            }
            else if (month == 10 || month == 11 || month == 12)
            {
                Console.WriteLine(month + "月份为冬季");
            }
        }

 

 

三、结果截图

 

posted on 2021-10-17 13:20  桑榆非晚柠月如风  阅读(11)  评论(0编辑  收藏  举报