java代码程序if elseif else生成流程图
时间: 2023-12-08 20:39:11 浏览: 205
以下是Java中if elseif else语句的示例代码和流程图:
```java
int score = (int) (Math.random() * 100); // 生成0~100的随机整数
if (score >= 85) {
System.out.println("等级A");
} else if (score >= 70) {
System.out.println("等级B");
} else if (score >= 60) {
System.out.println("等级C");
} else {
System.out.println("等级D");
}
```
流程图如下所示:
```
+-------+ true +--------+
| score |---------------------->| 等级A |
+-------+ +--------+
| |
| false |
| |
v v
+-------+ true +--------+
| score |---------------------->| 等级B |
+-------+ +--------+
| |
| false |
| |
v v
+-------+ true +--------+
| score |---------------------->| 等级C |
+-------+ +--------+
| |
| false |
| |
v v
+-------+ true +--------+
| score |---------------------->| 等级D |
+-------+ +--------+
```
阅读全文