forked from CPU-Code/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElse_if.java
More file actions
46 lines (40 loc) · 1012 Bytes
/
Copy pathElse_if.java
File metadata and controls
46 lines (40 loc) · 1012 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package src.judgment;
/*
* @Author: cpu_code
* @Date: 2020-07-07 08:52:44
* @LastEditTime: 2020-07-07 08:55:25
* @FilePath: \java\basics\else_if.java
* @Gitee: https://gitee.com/cpu_code
* @CSDN: https://blog.csdn.net/qq_44226094
*/
/**
* if…else if…else语句的使用
* 该成绩的等级为良
*/
public class Else_if
{
public static void main(String[] args)
{
int grade = 75; // 定义学生成绩
if (grade > 80)
{
// 满足条件 grade > 80
System.out.println("该成绩的等级为优");
}
else if (grade > 70)
{
// 不满足条件 grade > 80 ,但满足条件 grade > 70
System.out.println("该成绩的等级为良");
}
else if (grade > 60)
{
// 不满足条件 grade > 70 ,但满足条件 grade > 60
System.out.println("该成绩的等级为中");
}
else
{
// grade =< 60
System.out.println("该成绩的等级为差");
}
}
}