用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;//把分数等级还给调用者
      }
}

猜你喜欢

转载自www.cnblogs.com/LYY1084702511/p/10638268.html