编程实践6-2
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Achievement2 { class Program { static void Main(string[] args) { double dblStuScore; Console.WriteLine(" 学生成绩管理系统"); Console.WriteLine(" (输入-1退出系统)"); do { Console.Write("\n请输入学生的成绩:"); dblStuScore = Convert.ToDouble(Console.ReadLine()); if (dblStuScore == -1) { break; } if (dblStuScore < 0 || dblStuScore > 100) { Console.WriteLine("你输入的成绩不合法,请重新输入!"); } else { Console.WriteLine(chA(dblStuScore)); } } while (true); Console.WriteLine("\n谢谢使用学生成绩管理系统!"); Console.ReadKey(); } public static string chA(double iA) { string strOutput; switch ((int)(iA / 10)) { case 10: case 9: strOutput = "优秀"; break; case 8: strOutput = "良"; break; case 7: strOutput = "中"; break; case 6: strOutput = "及格"; break; default: strOutput = "不及格"; break; } return "成绩等级:" + strOutput; } } }