您好,我想请问下我这个只能输出平均成绩调用其他方法没有输出该怎么办
public class Student {
public String name;
public String gender;
public int age;
private double score;
public double getScore(){
return
score;
}
public void setScore(double score){
this.score =score;
}
public Student(String name,String gender,int age,double score) {
super();
this.name = name;
this.gender = gender;
this.age = age;
this.score = score;
}
public String toString() {
return "Student [name=" + name + ", gender=" + gender + ", age=" + age+ ", score=" + score + "]";}
public static void display(Student[]stu){
double sum = 0;
for (int i=0;i<stu.length;i++){
double s=stu[i].getScore();
sum=sum+s;
}
double a = sum/stu.length;
System.out.println("平均成绩为"+a);
}
public static void dp( Student[]stu){
System.out.println("学生成绩汇总表");
for(int i=0;i<stu.length;i++){
System.out.print(stu[i]+"\n");
}
}
public static void sort(Student[]stu){
for (int i= 0;i<stu.length;){
for (int j=i;j<stu.length;j++){
if(stu[i].getScore()<stu[j].getScore()){
Student tem =stu[j];
stu[j]=stu[i];
stu[i]=tem;
}
}
}
System.out.println("成绩最好的"+stu[0].toString());
System.out.println("成绩最差的"+stu[4].toString());
}
public static void main(String[] args) {
Student[ ]stu =new Student[5];
Student s1 =new Student("文津","女",20,95.5);
Student s2 =new Student("文明","女",21,90.2);
Student s3=new Student("文程·","男",22,89.1);
Student s4=new Student("文化","女",19,93.3);
Student s5=new Student("文完","女",21,97.4);
stu[0]=s1;
stu[1]=s2;
stu[2]=s3;
stu[3]=s4;
stu[4]=s5;
Student.display(stu);
Student.sort(stu);
Student.dp(stu);
}
}