根据输入的百分制成绩(score),要求输出成绩等级(grade)A、B、C、D、E。90分以上为A, *80~89分为B,70~79分为C,60~69分为D,60分以下为E。用if语句实现。

package practise001;

import java.util.Scanner;

/* 根据输入的百分制成绩(score),要求输出成绩等级(grade)A、B、C、D、E。90分以上为A,

 * 80~89分为B,70~79分为C,60~69分为D,60分以下为E。用if语句实现。
 */
/**
 ************************************
 * @author Hejing
 * @date   2017年12月9日
 * @class  t1.java
 *
 ************************************
 */
public class t1 {
    public static void main(String[] args) {
        System.out.println("请输入成绩:");
        Scanner sc =new Scanner(System.in );
        int score=sc.nextInt();
        String  grade=null ;
        if(score<60) {
            grade="E";    
        }
        if(score>=60&&score<=69) {
            grade="D";
            
        }
        if(score>=70&&score<=79) {
            grade="C";
            
        }
        if(score>=80&&score<=89) {
            grade="B";
        
        }
        if(score>=90) {
            grade="A";
            
        }        
        System.out.println("成绩等级grade:"+grade);
        }
        
    }

猜你喜欢

转载自blog.csdn.net/qq_37843372/article/details/79018843