day03-if语句案例
This commit is contained in:
32
day03/src/com/inmind/if01/Test04.java
Normal file
32
day03/src/com/inmind/if01/Test04.java
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user