package demo9;
public class Student {
private String name;
private int EnglishScore;
private int MathScore;
private int SportScore;
private Grade grade;
Student(){
}
Student(String name,int E,int M,int S){
this.name=name;
this.EnglishScore=E;
this.MathScore=M;
this.SportScore=S;
}
public double getAvgScore() {
return (EnglishScore+MathScore+SportScore)/3;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getEnglishScore() {
return EnglishScore;
}
public void setEnglishScore(int englishScore) {
EnglishScore = englishScore;
}
public int getMathScore() {
return MathScore;
}
public void setMathScore(int mathScore) {
MathScore = mathScore;
}
public int getSportScore() {
return SportScore;
}
public void setSportScore(int sportScore) {
SportScore = sportScore;
}
public Grade getGrade() {
return grade;
}
public void setGrade(Grade grade) {
this.grade = grade;
}
}
package demo9;
public enum Grade {
A,B,C,D
}
package demo9;
public class test2 {
public static int ANUm=0;
public static int BNUm=0;
public static int CNUm=0;
public static int DNUm=0;
public static void main(String[] args) {
Student []A=new Student[10];
A[0]=new Student("zhangsan",90,80,70);
A[1]=new Student("lisi",70,70,60);
A[2]=new Student("laobai",50,70,60);
A[3]=new Student("liswwi",60,50,60);
A[4]=new Student("liddsi",40,40,60);
A[5]=new Student("lissi",90,90,97);
A[6]=new Student("liedgfsi",30,70,100);
A[7]=new Student("lidfsi",80,80,89);
A[8]=new Student("ligdgsi",60,90,60);
A[9]=new Student("lisasi",70,90,60);
int i;
for(i=0;i<10;i++){
double b=A[i].getAvgScore();
if(b>=90){
A[i].setGrade(Grade.A);
ANUm++;
}
if(b>=80&&b<90){
A[i].setGrade(Grade.B);
BNUm++;}
if(b>=60&&b<80){
A[i].setGrade(Grade.C);
CNUm++;
}
if(b<60){
A[i].setGrade(Grade.D);
DNUm++;
}
}
System.out.println("A等级学生所占比为"+"0."+ANUm);
System.out.println("B等级学生所占比为"+"0."+BNUm);
System.out.println("C等级学生所占比为"+"0."+CNUm);
System.out.println("D等级学生所占比为"+"0."+DNUm);
}
}