每日博客

C#

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

using System;

namespace test

{

class test_1

    {

public void test_1_2()

        {

           int i=0;

            while (i!=13)

            {

                Console.WriteLine("请输入月份:(输入13退出)");

                i=int.Parse(Console.ReadLine());

                switch (i)

                {

                    case 3:

                    case 4:

                    case 5: Console.WriteLine("此月份在春季。。。"); break;

                    case 6:

                    case 7:

                    case 8: Console.WriteLine("此月份在夏季。。。"); break;

                    case 9:

                    case 10:

                    case 11: Console.WriteLine("此月份在秋季。。。"); break;

                    case 12:

                    case 1:

                    case 2: Console.WriteLine("此月份在冬季。。。"); break;

                    default: Console.WriteLine("输入错误!!!"); break;

                }

            }

        }

    }

    class main

    {

        static void Main(string[] args)

        {

            test_1 t = new test_1();

            t.test_1_2();

        }

    }

}

 

posted @ 2021-10-03 21:01  谦寻  阅读(24)  评论(0编辑  收藏  举报