switch语句编写一个成绩转换的java程序
时间: 2023-12-18 16:03:54 浏览: 128
程序举例switch语句
好的,以下是一个简单的成绩转换的Java程序,使用了switch语句:
```java
import java.util.Scanner;
public class GradeConverter {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("请输入成绩:");
int score = input.nextInt();
char grade;
switch (score / 10) {
case 10:
case 9:
grade = 'A';
break;
case 8:
grade = 'B';
break;
case 7:
grade = 'C';
break;
case 6:
grade = 'D';
break;
default:
grade = 'F';
}
System.out.println("成绩为:" + grade);
}
}
```
阅读全文