采用switch语句设计一个程序,对给定的学生成绩score评判其等级这个程序怎么编啊??
发布网友
发布时间:2022-04-29 18:52
我来回答
共2个回答
热心网友
时间:2023-10-27 08:06
public class Degree {
public String getDegree(int score) {
if (score < 0 || score > 100) {
return "分数格式非法";
}
int degree = score / 10;
switch (degree) {
case 10:
case 9:
return "优";
case 8:
return "良";
case 7:
return "中";
case 6:
return "及格";
default:
return "不及格";
}
}
public static void main(String[] args) {
Degree d = new Degree();
String result = d.getDegree(80);
System.out.println(result);
}
}
热心网友
时间:2023-10-27 08:06
int s=score/10;
switch(s){
case:10..
case:9..
case:8..
case:7..
case:6..
default..
}