编写一段程序java

编写一段程序,运行时向用户提问“你考了多少分?(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);
    }
import java.util.Scanner;

public class GradeJudgment {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("你考了多少分?(0~100)");
        int score = input.nextInt();

        if (score >= 90 && score <= 100) {
            System.out.println("你的等级是优。");
        } else if (score >= 80 && score <= 89) {
            System.out.println("你的等级是良。");
        } else if (score >= 60 && score <= 69) {
            System.out.println("你的等级是中。");
        } else if (score >= 0 && score <= 59) {
            System.out.println("你的等级是差。");
        } else {
            System.out.println("输入的分数不合法。");
        }
    }
}

不知道你这个问题是否已经解决, 如果还没有解决的话:

如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^