0
点赞
收藏
分享

微信扫一扫

java基础经典练习题——5

陌岛 2022-03-11 阅读 54

程序5】   
题目:利用条件运算符的嵌套来完成此题:学习成绩80~100分的同学优秀,60-80分之间良,60分以下不及格,输入成绩查看自己的评价。

public class lx05 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入你的成绩:");
        int score = sc.nextInt();
        if (score >= 80 && score <= 100){
            System.out.println("你的成绩:优秀");
        }else if (score >= 60 && score < 80 ){
            System.out.println("你的成绩:良");
        }else if (score >= 0 && score < 60){
            System.out.println("你的成绩:不及格");
        }else {
            System.out.println("请输入正确的分数!");
        }
    }
}
举报

相关推荐

0 条评论