package com.fun;
import java.util.Scanner;
/*
* 输入学生个数,成绩然后输出最大值,根据每个分数与最大值的差来判断分数等级。
*/
public class Test1 {
public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner sc = new Scanner(System.in);
System.out.println("请输入学生人数:");
int num = sc.nextInt();
int arr[] = new int[num];
System.out.println("请输入" + num + "个成绩:");
int max = 0;
for(int i = 0 ; i < num ; i ++) {//判断最大值
int score = sc.nextInt();//输入
arr[i] = score;
if(score > max) {
max = score;
}
}
System.out.println("最高分是:"+ max);
char ji;//判断学生成绩等级
for(int j = 0;j < num; j++) {
int cha = max - arr[j];
if(cha <= 10) {
ji = 'A';
}
else if(cha<=20&&cha>10) {
ji = 'B';
}
else if(cha<=30&&cha>20) {
ji = 'C';
}
else {
ji = 'D';
}
int b = j+1;
System.out.println("Student:"+ b +"\tScore:\t"+ arr[j] + "\t等级为:" + ji);
}
}
}
输入学生个数,成绩然后输出最大值,根据每个分数与最大值的差来判断分数等级。
于 2022-10-25 17:41:45 首次发布