编写一段程序,运行时向用户提问“你考了多少分?(0~100)”,接受输入后判断其等级并显示出来。
判断依据如下:
等级={优(90100 分);良(8089 分);中(6069 分);差(059 分);}
编写一段程序,运行时向用户提问“你考了多少分?(0~100)”,接受输入后判断其等级并显示出来。
判断依据如下:
等级={优(90100 分);良(8089 分);中(6069 分);差(059 分);}
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.println("你考了多少分?(0~100)");
int score = scanner.nextInt();
String level;
if (score >= 90 && score <= 100) {
level = "优";
} else if (score >= 80 && score <= 89) {
level = "良";
} else if (score >= 60 && score <= 69) {
level = "中";
} else if (score >= 0 && score <= 59) {
level = "差";
} else {
level = "输入有误";
}
System.out.println("你的等级是:" + level);
}