-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathShowGradeMulti.java
More file actions
38 lines (35 loc) · 928 Bytes
/
Copy pathShowGradeMulti.java
File metadata and controls
38 lines (35 loc) · 928 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
import java.util.Scanner;
public class ShowGradeMulti {
public static void main(String[] args) {
float grade = 0; // 百分制成绩
Scanner console = new Scanner(System.in);
System.out.print("请输入成绩:");
grade = console.nextFloat();
while(grade >= 0) {
showGrade(grade);
grade = console.nextFloat();
}
}
private static void showGrade(float grade) {
String gradeLevel = ""; // 等级分
int level = (int)grade / 10; // 转换为整数
switch(level) {
case 10:
case 9:
gradeLevel = "优秀";
break;
case 8:
gradeLevel = "良好";
break;
case 7:
gradeLevel = "中等";
break;
case 6:
gradeLevel = "及格";
break;
default:
gradeLevel = "不及格";
}
System.out.println("输入成绩为:" + grade + ",成绩等级为:" + gradeLevel);
}
}