天天看點

JAVA 成績等級劃分

  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");
            }
        }
    }