傳智播客.Net培訓就業班入學測試題

來源:互聯網
上載者:User

標籤:

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();        }    }}

 

傳智播客.Net培訓就業班入學測試題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.