day03--if的综合小案例

This commit is contained in:
2026-09-15 16:10:46 +08:00
parent e1c6c346b5
commit 1be168834b
+35
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 Test02 {
public static void main(String[] args) {
//1.定义一个成绩变量score
int score = 120;
//2.使用if格式三,根据不同的判断条件,输出各自学生的等级
if(score>=90 && score<=100){
System.out.println("优秀");
}else if(score>=80 && score<=89){
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("程序结束");
}
}