成绩等级计算关键算法



输入一批学生成绩,以-1作为结束标记 。统计这批学生中,不及格(score<60)、及格(60<=score<70)、中等(70<=score<80)、良好(80<=score<90)、优秀(90<=score<=100)的人数。

注意:使用分支、循环结构语句实现。

package fouth;

import java.util.Scanner;

public class two {
    public static void main(String[] args) {
        int a=0,b=0,c=0,d=0,e=0;
        Scanner scanner=new Scanner(System.in);
        int score;
        do {
            System.out.println("请输入学生成绩:");
            score =scanner.nextInt();
            if (0<score && score<60){
                a++;
            }else if (60<=score && score<70){
                b++;
            }else if (70<=score && score<80){
                c++;
            }else if (80<=score && score<90){
                d++;
            }else if (90<=score && score<=100){
                e++;
            }
        }while (score!=-1);
        System.out.println("不及格的有"+a+"人");
        System.out.println("及格的有"+b+"人");
        System.out.println("中等的有"+c+"人");
        System.out.println("良好的有"+d+"人");
        System.out.println("优秀的有"+e+"人");







    }
}

  


免责声明!

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



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