編寫一段程序,運行時向用戶提問“你考了多少分?(0~100)”,接受輸入后判斷其等級並顯示出來。判斷依據如下:等級={優 (90~100分);良 (80~89分);中 (60~69分);差 (0~59分);}


 編寫一段程序,運行時向用戶提問“你考了多少分?(0~100)”,接受輸入后判斷其等級並顯示出來。判斷依據如下:等級={優 (90~100分);良 (80~89分);中 (60~69分);差 (0~59分);}

 

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Linq;
 4 using System.Text;
 5 using System.Threading.Tasks;
 6 
 7 namespace 貼吧01
 8 {
 9     class Program
10     {
11         static void Main(string[] args)
12         {
13             int input;
14             //Console.WriteLine("你考了多少分?(0~100)");
15             while (true)
16             {
17                 Console.WriteLine("你考了多少分?(0~100)");
18                 input = Convert.ToInt32(Console.ReadLine());
19                 if ((input >= 90) && (input <= 100))
20                 {
21                     Console.WriteLine("");
22                     break;
23                 }
24                 else if (input >= 80)
25                 {
26                     Console.WriteLine("");
27                     break;
28                 }
29                 else if ((input >= 60) && (input <= 69))
30                 {
31                     Console.WriteLine("");
32                     break;
33                 }
34                 else if ((input >= 0) && (input <= 59)) //0-59
35                 {
36                     Console.WriteLine("");
37                     break;
38                 }
39                 else
40                 {
41                     Console.WriteLine("輸入有誤或者所輸入的不是要求的有效成績范圍");
42                 }
43             }
44             Console.ReadKey();
45         }
46     }
47 }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2026 CODEPRJ.COM