38. 成绩等级
语法讲解
今天学: 用多个 else if 实现区间分类。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int s = sc.nextInt();
if (s >= 90) {
System.out.println("A");
} else if (s >= 80) {
System.out.println("B");
} else if (s >= 60) {
System.out.println("C");
} else {
System.out.println("D");
}
}
}
小练习
输入 85,输出是什么?
输入: 85
提交要求: 只提交最终输出结果,不要添加多余的说明或引号。
全部评论