传智播客.Net培训就业班入学测试题

2、对学员的结业考试成绩评测,要求在控制台中提示用户输入学员考试成绩,写一个方法,根据用户输入的成绩,返回一个等级;
90分以上A级、80~90分B级、70~80分C级、60~70分B级、60分以下C级。

如图所示:
传智播客.Net培训就业班入学测试题

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("请输入你的考试成绩:");

            int score =Convert.ToInt32(Console.ReadLine());

            switch (score/10)

            {

                case 10:

                Console.WriteLine("非常棒!");

                break;

                case 9:

                Console.WriteLine("优秀");

                break;

                case 8:

                Console.WriteLine("优秀");

                break;

                case 7:

                Console.WriteLine("良好");

                break;

                case 6:

                Console.WriteLine("及格");

                break;

                default:

                Console.WriteLine("不及格!");

                break;

            }

            Console.ReadLine();

        }

    }

}

3、在控制台中提示用户输入一个年龄,如果用户输入的年龄大于18岁,则提示用户”可以查看”,如果小于10岁,则提示用户“不可以查看”,如果在10岁到18岁之间,则提示用户 “是否继续查看?(yes/no)”,如果用户输入yes,则提示可以查看,否则提示不可以查看。

如图所示:
传智播客.Net培训就业班入学测试题

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("请输入你的年龄:");

            int age =Convert.ToInt32(Console.ReadLine());

            if (age>= 18)

            {

                Console.WriteLine("可以查看!");

            }

            if (age < 18 && age >= 10)

            {

                Console.WriteLine("看请输入Y,不看输入N");

                string str = Console.ReadLine();

                if (str == "y" || str == "Y")

                {

                    Console.WriteLine("强行查看");

                }

                else

                {

                    Console.WriteLine("88");

                }

            }

            if (age < 10)

            {

                Console.WriteLine("年龄太小不可以查看");

            }

            Console.ReadLine();

        }

    }

}

4、在控制台中提示用户首先输入一个年份,再提示用户输入一个月份,请根据用户输入的年份和月份来输出这个月有多少天(需要判断是否是闰年)。

如图所示:
传智播客.Net培训就业班入学测试题 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;



namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            Console.WriteLine("请输入年分");

            int year = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("请输入月分");

            int month = Convert.ToInt32(Console.ReadLine());

            if(month == 2)

            {

                if (year % 4 == 0)

                {

                    Console.WriteLine("{0}年{1}月有29天", year, month);

                }

            }

            else

            {

                int[] arr = new int[] { 1, 3, 5, 7, 8, 10, 12 };

                

                if ((Array.IndexOf(arr, month)) == -1)

                {

                    Console.WriteLine("{0}年{1}月有30天", year, month);

                }

                else

                {

                    Console.WriteLine("{0}年{1}月有31天", year, month);

                }

            }

            Console.ReadLine();

        }

    }

}

 

你可能感兴趣的:(.net)