import java.util.*;
public class Gradebook
{
//类成员
private String TeacherName;
private String CourseName;
private int stu_num;
private String []stu;
private int [] grade;
private int max,min;
private double avg;
//g 2
public Gradebook(){}
public Gradebook(String Tname,String Cname,int t)
{
TeacherName=Tname;
CourseName=Cname;
stu_num=t;
}
set and get
public void SetTeacherName(String tname)
{
TeacherName=tname;
}
public void ShowTeacherName()
{
System.out.println("该课程老师是:\t"+TeacherName);
}
set and get
public void SetCourseName(String cname)
{
CourseName=cname;
}
public void ShowCourseName()
{
System.out.println("该课程是:\t"+CourseName);
}
///set and get
public void setnum(int t){stu_num=t;}
public int getnum(){return stu_num;};
//set grades
public void setgrade(int[] tnum)
{
grade=new int[getnum()];
for(int i=0;i<getnum();i++)
{
grade[i]=tnum[i];
}
}
//
public void getmmm()
{
int tmax,tmin,tsum;
tmax=tmin=tsum=grade[0];
for(int i=1;i<getnum();i++)
{
tsum+=grade[i];
if(grade[i]>max) max=grade[i];
else
if(grade[i]<min) min=grade[i];
}
max=tmax;min=tmin;avg=1.0*tsum/getnum();
}
//
public void output()
{
getmmm();
System.out.println("最大值为"+max);
System.out.println("最小值为"+max);
System.out.println("平均值为"+avg);
}
//
public static void main(String[] args)
{
Gradebook a=new Gradebook("java程序设计","张教授",3);
a.ShowTeacherName();
a.ShowCourseName();
a.SetTeacherName("new 张教授");
a.SetCourseName("new java程序设计");
a.ShowTeacherName();
a.ShowCourseName();
int []tnum=new int[100];
tnum[0]=60;
tnum[1]=70;
tnum[2]=80;
a.setgrade(tnum);
a.output();
}
}