写一个程序,运用switch语句,输入学生成绩,给出相应等级
1个回答
展开全部
/// <summary>
/// 根据输入的学生成绩判断等级
/// </summary>
/// <param name="StudScore">输入的学生成绩</param>
/// <returns>返回学生成绩对应的等级</returns>
public string GetStudentGradeByScore(int StudScore)
乎顷 {
string grade = "";//等级
int sw = 0;
if (StudScore < 60)
{
sw = 5;
}
else if (StudScore < 75 && StudScore>=60)
{
sw = 4;
}
else if (StudScore < 90 && StudScore>=75)
渣顷轿 {
sw = 3;
}
else if (StudScore < 100 && StudScore >= 90)
{
如肆 sw = 2;
}
else {
sw = 1;
}
switch (sw) {
case 1: grade = "优+/A+"; break;
case 2: grade = "优/A"; break;
case 3: grade = "中/B"; break;
case 4: grade = "良/C"; break;
case 5: grade = "不及格/D"; break;
default: break;
}
return grade;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询