package 成绩统计;
import java.util.Scanner;
public class ScoreCensus {
private double Math=0;
private double English=0;
private double Physical=0;
public void Input(int i)
{
Scanner Sc=new Scanner(System.in);
System.out.print("输入第"+(i+1));
System.out.println("个学生的成绩信息:");
System.out.println("Math: ");
this.Math=Sc.nextDouble();
System.out.println("English: ");
this.English=Sc.nextDouble();
System.out.println("Physical: ");
this.Physical=Sc.nextDouble();
}
public double Sum()
{
return (this.Math+this.English+this.Physical);
}
public double average()
{
double s;
s=this.Sum()/3;
return s;
}
public static void main(String[] args) {
ScoreCensus s[]=new ScoreCensus[10];//使用对象数组要进行实例化,否则出现异常
int i;
for(i=0;i<s.length;i++)
{
s[i]=new ScoreCensus();//实例化
s[i].Input(i);
System.out.println(+s[i].Sum());
System.out.println(+s[i].average());
}
}
}