凉渃渃 2021-04-15 17:04 采纳率: 80%
浏览 29
已采纳

java新手问题 方法引用方面求救Q.Q

import java.util.Scanner;
public class GradesRank{
 public static void main(String args[]){
 System.out.println("please input the students'name,ID,scores and individe them by','");
 Student student1=new Student();
 Student student2=new Student();
 Student student3=new Student();
 Student student4=new Student();
 Student student5=new Student();
 Student student6=new Student();
 Student student7=new Student();
 Student student8=new Student();
 Student student9=new Student();
 Student student10=new Student();
 Student[] ary=new Student[10];
 ary[0]=student1;
 ary[1]=student2;
 ary[2]=student3;
 ary[3]=student4;
 ary[4]=student5;
 ary[5]=student6;
 ary[6]=student7;
 ary[7]=student8;
 ary[8]=student9;
 ary[9]=student10;
 for(int i=0;i<10;i++){
	ary[i].Score(ary[i]);
   }
 for(int i=0;i<10;i++){
	for(int j=0;j<9;j++){
		if(ary[j].total>ary[j+1].total){
			Student y=new Student();
			y=ary[j];
			ary[j]=ary[j+1];
			ary[j+1]=y;
		}
	}
  }
 
  System.out.println("the rank is: ");
 for(int i=0;i<10;i++){
	 System.out.println(ary[i].name+"  "+ary[i].total+"   "+(i+1));
	
 }
   
 

 }


}
class Student{
 public String name;
 public String ID;
 public double score1;
 public double score2;
 public double score3;
 public double score4;
 public double score5;
 public double score6;
 public double total;
}



class Score{
 public void Score(Student s){
 Scanner input=new Scanner(System.in);
 String a=input.nextLine();
 String [] p=a.split(",");
 s.name=p[0];
 s.ID=p[1];
 int []shu=new int[p.length];
 for(int i=2;i<p.length;i++){
    shu[i]=Integer.parseInt(p[i]);
    }
 s.score1=shu[2];
 s.score2=shu[3];
 s.score3=shu[4];
 s.score4=shu[5];
 s.score5=shu[6]; 
 s.score6=shu[7];
 s.total=s.score1+s.score2+s.score3+s.score4+s.score5+s.score6;
 }

}


 
 

  • 写回答

3条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 关于selenium网页闪退
      • ¥15 怎么用PYTHON解类似于x = y+zx + cy = x+zy + v的方程
      • ¥300 FLASH AS2.0制作一个类似手机上下滑动一样的效果
      • ¥15 为什么使用openFoam 中的icoFoam计算圆柱扰流时出现浮点数例外(核心已转储)
      • ¥15 51单片机外部中断控制数码管
      • ¥15 创建网页里面的图片显示不出来
      • ¥15 语音控制的编写?(语言-c#)
      • ¥15 matlab输入书上的代码运行错误
      • ¥15 matlab怎么做三维曲面
      • ¥50 sph光滑粒子法能否解决阶跃性的问题