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


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

    如图所示:

    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,则提示可以查看,否则提示不可以查看。

    如图所示:

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

    如图所示:
     

    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();
            }
        }
    }
    
  • 相关阅读:
    递归练习:走台阶
    递归练习:计算最大公约数和最小公倍数
    递归练习:逆序输出一个十进制数的各位数字
    m4, autoconf
    Makefile 和 CMakeLists.txt
    Java中的String pool
    小米路由Mini刷Breed, 潘多拉和LEDE
    Centos 编译LEDE/OpenWrt
    Centos6下编译安装gcc6.4.0
    IntelliJ IDEA遇到Unable to parse template “Class”错误
  • 原文地址:https://www.cnblogs.com/tangt/p/4195879.html
Copyright © 2020-2023  润新知