高手给看看哪里出错了,,
import java.util.*;class student
{
private String name;
private String sex;
private String password="000000";
private String num;
private double score[];
private double sum=0;
student()
{
}
Scanner sc=new Scanner(System.in);
student(String name,String num,String sex,double score[] )
{
this.name=name;
this.num=num;
this.sex=sex;
for(int i=0;i<score.length;i++)
{
this.score[i]=score[i];
sum=sum+score[i];
}
}
void setName(String name)
{
this.name=name;
}
void setSex(String sex)
{
this.sex=sex;
}
void setNum(String num)
{
this.num=num;
}
void setPassword()
{
String q;
System.out.println("please input old password");
q=sc.next();
if(q.equals(password))
{
System.out.println("please input new password");
String w=sc.next();
password=w;
}
}
void set(String name,String num,String sex,double score[])
{
this.name=name;
this.num=num;
this.sex=sex;
this.score=new double[score.length];
for(int i=0;i<score.length;i++)
{
this.score[i]=score[i];
sum=sum+score[i];
}
}
String getName()
{
return name;
}
String getSex()
{
return sex;
}
String getnum()
{
return num;
}
String getPassword()
{
return password;
}
double [] getScore()
{
return score;
}
double getSum()
{
return sum;
}
void print()
{
System.out.println("学生\t"+"姓别\t"+"学号\t"+"英语\t"+"数学\t"+"java\t"+"C++\t"+"线代\t");
System.out.print(name+"\t");
System.out.print(sex+"\t");
System.out.print(num+"\t");
for(int i=0;i<score.length;i++)
{
System.out.print(score[i]+"\t");
}
System.out.println("");
}
}
class astudent
{
private student stu[];
int len=0;
astudent()
{
stu= new student[3];
for(int i=0;i<stu.length;i++ )
stu[i]=new student();
}
Scanner ss= new Scanner(System.in );
void paixu ()
{
student d[]=new student[len];
for(int i=0;i<d.length;i++)
{
d[i]=new student();
d[i].set(stu[i].getName(),stu[i].getnum(),stu[i].getSex(),stu[i].getScore());
}
for(int j=0;j<d.length;j++)
{
for(int i=0;i<d.length-j;i++)
if(d[j].getSum()>d[i+1].getSum())
{
student p=new student();
p.set(d[j].getName(),d[j].getnum(),d[j].getSex(),d[j].getScore());
d[j].set(d[i+1].getName(),d[i+1].getnum(),d[i+1].getSex(),d[i+1].getScore());
d[i+1].set(p.getName(),p.getnum(),p.getSex(),p.getScore());
}
}
for(int i=0;i<stu.length;i++)
d[i].print();
}
void input()
{
double cheng[]=new double[5];
String e="#";
for(int i=0;i<stu.length;i++)
{
int k=i+1;
System.out.println("请输入第"+k+"个学生的姓名");
String name=ss.next();
System.out.println("请输入第"+k+"个学生的学号");
String num=ss.next();
System.out.println("请输入第"+k+"个学生的性别");
String sex=ss.next();
System.out.println("请输入第"+k+"个学生的英语,数学,java,c++,线代成绩");
for(int j=0;j<5;j++)
{
cheng[j]=ss.nextDouble();
}
stu[len].set(name,num,sex,cheng);
len++;
}
}
void output()
{
for(int i=0;i<stu.length;i++)
stu[i].print();
}
void changepass()
{
System.out.print("请输入修改密码的学生的学号");
int y=ss.nextInt();
stu[y-1].setPassword();
}
void dele()
{
System.out.println("please input num");
int l=ss.nextInt();
System.out.println("please input password");
String h=ss.next();
if(h.equals(stu[l-1].getPassword()))
{
for(int i=l-1;i<stu.length-1;i++)
stu[i].set(stu[i+1].getName(),stu[i+1].getnum(),stu[i+1].getSex(),stu[i+1].getScore());
System.out.println("删除成功");
}
else System.out.println("删除失败");
}
void change()
{
double p[]=new double[5];
System.out.println("please input num");
int l=ss.nextInt();
System.out.println("please input password");
String h=ss.next();
if(h.equals(stu[l-1].getPassword()))
{
System.out.println("请输个学生的姓名");
String name=ss.next();
System.out.println("请输入学生的学号");
String num=ss.next();
System.out.println("请输入学生的性别");
String sex=ss.next();
System.out.println("请输入学生的英语,数学,java,c++,线代成绩");
for(int j=0;j<5;j++)
{
p[j]=ss.nextDouble();
}
stu[l-1].set(name,num,sex,p);
System.out.println("修改成功");
}
else System.out.println("修改失败");
}
void find()
{
System.out.println("please input id");
String f=ss.next();
for(int i=0;i<len;i++)
{
if(f.equals(stu[i].getnum()))
{
stu[i].print();
}
else System.out.println("Eorro");
}
}
void charu()
{
System.out.println("please input cha ru weizhi");
int y=ss.nextInt();
double p[]=new double[5];
for(int i=len;i>y;i--)
{
stu[i].set(stu[i-1].getName(),stu[i-1].getnum(),stu[i-1].getSex(),stu[i-1].getScore());
}
System.out.println("请输个学生的姓名");
String name=ss.next();
System.out.println("请输入学生的学号");
String num=ss.next();
System.out.println("请输入学生的性别");
String sex=ss.next();
System.out.println("请输入学生的英语,数学,java,c++,线代成绩");
for(int j=0;j<5;j++)
{
p[j]=ss.nextDouble();
}
stu[y-1].set(name,num,sex,p);
}
void cover()
{
System.out.println("\t\t学生成绩管理系统");
System.out.println("\t\t 版本1.0");
System.out.println("\n\n\n");
System.out.println("\t\t 李云强");
System.out.println("\t\t 2010.5.15");
//int p=ss.nextInt();
//Runtime.getRuntime().exec(".\\cls");
}
int menu()
{
System.out.println("\t\t学生成绩管理系统");
System.out.println("\n\n\n");
System.out.println("\t\t 1"+" "+"输入");
System.out.println("\t\t 2"+" "+"显示");
System.out.println("\t\t 3"+" "+"排序");
System.out.println("\t\t 4"+" "+"改密");
System.out.println("\t\t 5"+" "+"删除");
System.out.println("\t\t 6"+" "+"修改");
System.out.println("\t\t 7"+" "+"插入");
System.out.println("\t\t 8"+" "+"查找");
System.out.println("\t\t 0"+" "+"退出");
System.out.println("请输入要选择的选项");
int t=ss.nextInt();
return t;
}
}
class system1
{
public static void main(String args[])
{
Scanner so=new Scanner(System.in);
astudent a=new astudent();
a.cover();
// String e=so.next();
while(true)
{
int ch=a.menu();
switch(ch)
{
case 1:a.input();break;
case 2:a.output();break;
case 3:a.paixu();break;
case 4:a.changepass();break;
case 5:a.dele();break;
case 6:a.change();break;
case 7:a.charu();break;
case 8:a.find();break;
case 0:System.exit(0);
}
}
}
}这个程序运行到排序的时候就出错了???
不知为什么