小题目—成绩划分等级

  1. package 成绩等级;
    
    import com.sun.jdi.event.Event;
    import com.sun.jdi.event.ExceptionEvent;
    
    import java.util.Scanner;
    
    public class Score {
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            System.out.println("请输入成绩:");
            double score = scanner.nextDouble();
            scanner.close();
    //判断语句
            if (score > 100 || score < 0) {
                System.out.println("输入的成绩不在0~100的范围内");
            } else if (score >= 90) {
                System.out.println("A");
            } else if (score >= 80) {
                System.out.println("B");
            } else if (score >= 60) {
                System.out.println("C");
            } else {
                System.out.println("D");
            }
        }
    }

猜你喜欢

转载自blog.csdn.net/qq_40825218/article/details/81181243