帮我看下这个关于继承程序!
import java.util.Scanner;abstract class person
{
String name;
String sex;
int age;
protected void person()
{
Scanner reader=new Scanner(System.in);
System.out.print("请输入姓名:");
name=reader.nextLine();
System.out.print("请输入性别:");
sex=reader.nextLine();
System.out.print("请输入年龄:");
age=reader.nextInt();
}
abstract public void show1();
/* abstract public void show2();*/
}
class student extends person
{
String num;
String classdry;
/*double chinese;
double math;
double english;*/
static String course;
static double score;
static double sum=0;
public static double total(int m)
{
int i;
for(i=0;i<m-1;i++)
{sum=sum+score;
// System.out.print("\n总分:"+sum);
}
return(sum);
}
public static double average(int m)
{
double avg;
avg=sum/m;
//System.out.print("平均分:"+avg);
return(avg);
}
protected void print1()
{
Scanner reader=new Scanner(System.in);
System.out.println("请输入学生基本信息!");
System.out.print("请输入学号:");
num=reader.nextLine();
super.person();
System.out.print("请输入是否是班干部:");
classdry=reader.nextLine();
/*System.out.print("请输入语文成绩:");
chinese=reader.nextInt();
System.out.print("请输入数学成绩:");
math=reader.nextInt();
System.out.print("请输入外语成绩:");
english=reader.nextInt();*/
}
public static void print2(student stu[],int m)
{
for(int j=0;j<m;j++)
{
Scanner reader=new Scanner(System.in);
System.out.println("请输入课程名及其成绩:");
course=reader.nextLine();
score=reader.nextDouble();
System.out.println(course+"的成绩"+score);
}
}
public void show1()
{
System.out.print("学号:"+num+" "+"姓名:"+name+" "+"性别:"+sex+" "+"年龄:"+age+" "+"是否是班干:"+classdry);
}
/* public void show2()
{
System.out.print("\n"+course+"成绩"+score);
}*/
/* public static void sorting(student stu[],int n)
{
int i,j;
student t;
for(j=0;j<n-1;j++)
for(i=0;i<n-1-j;i++)
if(stu[i].total()<stu[i+1].total())
{t=stu[i];stu[i]=stu[i+1];stu[i+1]=t;}
for(i=0;i<n;i++)
System.out.println("第"+(i+1)+"名为:"+stu[i].name+"总分为:"+stu[i].total());
}*/
}
class computer extends student
{
private String department;
// private double java;
void comstudent(String dep)
{
department=dep;
System.out.print(" 系别:"+department);
}
}
class allstudent
{
public static void main(String args[])
{
int n,m;
Scanner reader=new Scanner(System.in);
System.out.print("请输入你想输入多少个学生资料:");
n=reader.nextInt();
System.out.print("请输入你想输入的课程数:");
m=reader.nextInt();
computer stu[];
stu=new computer[n];
for(int i=0;i<n;i++)
{
stu[i]=new computer();
stu[i].print1();
computer.print2(stu,m);
stu[i].show1();
stu[i].comstudent("计算机科学系");
//stu[i].show2();
System.out.print("\n总分为"+student.total(m)+","+"平均分为"+student.average(m));
System.out.println();
}
// computer.sorting(stu,n);
}
}
其中算总分和平均分那里不知道怎么写!上面的程序就那里有问题!但找不出来!能运行,但算的总分错的!