Java--采用嵌套式多分支结构评定成绩等级
在
t03
包里创建p02
类
public class p02 {
public static void main(String[] args) {
//声明部分
int score;
String level;
Scanner sc = new Scanner(System.in);
//输入部分
System.out.println("score = ");
score = sc.nextInt();
//处理部分
level = "";
if (score > 100) {
level = "超出范围";
} else{
if (score >= 90) {
level = "优秀";
} else{
if (score >=80) {
level = "良好";
} else{
if (score >=70) {
level = "中等";
} else {
if (score >=60) {
level = "及格";
} else {
if (score >= 0) {
level = "不及格";
} else {
if (score < 0) {
level = "超出范围";
}
}
}
}
}
}
}
//输出部分
System.out.println(level);
}
}