胡萝贝贝 2021-11-23 14:58 采纳率: 37.5%
浏览 78
已结题

根据输入不同分数输出成绩等级

img

  • 写回答

3条回答 默认 最新

  • -Undefined_ 2021-11-23 15:32
    关注
    public class TestMain {
        public static void main(String[] args) {
            displayTitle();
            while(true){
                int s = getExam();
                String info = determineGrade(s);
                showMessage(info);
            }
        }
        public static void displayTitle(){
            System.out.println("Grade Classifier");
            System.out.println("****************\n");
        }
        public static int getExam(){
            Scanner sc = new Scanner(System.in);
            System.out.print("Enter exam mark:> ");
            return sc.nextInt();
        }
        public static String determineGrade(int score){
            String g;
            if(score>=70 && score<=100){
                g = "Congratulations,you are awarded a Grade A Pass.";
            }else if(score>=60 && score<=69){
                g = "Congratulations,you are awarded a Grade B Pass.";
            }else if(score>=50 && score<=59){
                g = "Congratulations,you are awarded a Grade C Pass.";
            }else if(score>=40 && score<=49){
                g = "Congratulations,you are awarded a Grade D Pass.";
            }else{
                g = "Unfortunately,you are awarded a Grade F Fail.";
            }
            return g;
        }
    
        public static void showMessage(String g){
            System.out.println(g);
        }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

问题事件

  • 系统已结题 12月1日
  • 已采纳回答 11月23日
  • 创建了问题 11月23日

悬赏问题

  • ¥100 华为手机私有App后台保活
  • ¥20 有谁能看看我coe文件到底哪儿有问题吗?
  • ¥20 我的这个coe文件到底哪儿出问题了
  • ¥15 matlab使用自定义函数时一直报错输入参数过多
  • ¥15 设计一个温度闭环控制系统
  • ¥100 rtmpose姿态评估
  • ¥15 java 通过反射找路径下的类,打包后就找不到
  • ¥15 通联支付网上收银统一下单接口
  • ¥15 angular有偿编写,
  • ¥15 centos7系统下abinit安装时make出错