day03-if的综合小案例

This commit is contained in:
2026-07-16 14:19:41 +08:00
parent 71260d85cd
commit 36b81791ab

View File

@@ -0,0 +1,35 @@
package com.inmind.if01;
/*
指定考试成绩,判断学生等级
90-100 优秀
80-89 好
70-79 良
60-69 及格
60以下 不及格
分析:
1.定义一个成绩变量score
2.使用if格式三根据不同的判断条件输出各自学生的等级
*/
public class Demo02 {
public static void main(String[] args) {
//定义一个成绩变量score
int score = 80;
if (score >= 90 && score <= 100) {
System.out.println("优秀");
} else if (score >= 80 && score <90) {
System.out.println("");
}else if(score>=70 && score<=79){
System.out.println("");
}else if(score>=60 && score<=69){
System.out.println("及格");
}else if(score<=59&&score>=0){
System.out.println("不及格");
}else{//else是可以不写要不要写要根据具体的业务题目来分析
System.out.println("您输入的成绩有误");
}
System.out.println("程序结束");
}
}