if的多种选择

2021-09-08  本文已影响0人  哈迪斯Java

package Structure;

import java.util.Scanner;

public class IfDemon3 {
public static void main(String[] args) {
//考试成绩大于60为几及格,否则就是不及格
Scanner scanner = new Scanner(System.in);
System.out.println("请输入成绩:");
int score = scanner.nextInt();

    if (score == 100) {
        System.out.println("恭喜满分");
    } else if (score < 100 && score >= 90) {
        System.out.println("恭喜优秀");
    } else if (score < 90 && score >= 80) {
        System.out.println("恭喜优秀");
    } else if (score < 80 && score >= 60) {
        System.out.println("良好,继续加油");
    } else if (score < 60 && score >= 0) {
        System.out.println("不及格");
    } else {
        System.out.println("成绩无效");
    }
}

}

上一篇下一篇

猜你喜欢

热点阅读