day03-if的综合小案例
This commit is contained in:
35
day03/src/com/inmind/if01/Demo02.java
Normal file
35
day03/src/com/inmind/if01/Demo02.java
Normal 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("程序结束");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user