day03-if语句案例

This commit is contained in:
2026-04-25 10:42:55 +08:00
parent 88f11c28c2
commit 27ce99fd72

View File

@@ -0,0 +1,32 @@
package com.inmind.if01;
/*
指定考试成绩,判断学生等级
90-100 优秀
80-89 好
70-79 良
60-69 及格
60以下 不及格
*/
public class Test04 {
public static void main(String[] args) {
//定义成绩
int score = 50;
String result;
//多条件判断,得出结果
//ctrl+D:复制当行内容
if (score >= 90 && score <= 100) {
result = "优秀";
} else if (score >= 80 && score <= 89) {
result = "";
}else if (score >= 70 && score <= 79) {
result = "良好";
} else if (score >= 60 && score <= 69) {
result = "及格";
} else {
result = "不及格";
}
System.out.println("当前成绩为:"+result);
}
}