用java输入分数,得出分数等级


import java.util.Scanner;
public class F {
 public static void main(String[] args) {
  // TODO 自动生成的方法存根
   Scanner in=new Scanner(System.in);
   int a;
   a=in.nextInt();
      String result=getGrade(a);//调用函数
      System.out.println("对应等级为:"+result);
 }
      public static String getGrade(int score){
       String grade="";//用于储存对应的等级
       if(score>=90&&score<=100){
        grade="A";
       }else if(score>=80&&score<=89){
        grade="B";
       }else if(score>=70&&score<=79){
        grade="C";
       }else if(score>=60&&score<=69){
        grade="D";
       }else if(score>=0&&score<=59){
        grade="E";
       }return grade;//把分数等级还给调用者
      }
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM