日期:2014-05-20 浏览次数:20845 次
class Student
{
private String name;
private float englishScore;
private float computerScore;
private float historyScore;
private float mathematicsScore;
public void setname(String s)
{
this.name=s;
}
public void setenglishScore(float n)
{
this.englishScore=n;
}
public void setcomputerScore(float n)
{
this.computerScore=n;
}
public void sethistoryScore(float n)
{
this.historyScore=n;
}
public void setmathematicsScore(float n)
{
this.mathematicsScore=n;
}
public String getname()
{
return this.name;
}
public float getenglishScore()
{
return this.englishScore;
}
public float getcomputerScore()
{
return this.computerScore;
}
public float gethistoryScore()
{
return this.historyScore;
}
public float getmathematicsScore()
{
return this.mathematicsScore;
}
public Student(String s)
{
this.setname(s);
}
public float totalScore()
{
float total=this.getenglishScore()+this.getcomputerScore()+this.gethistoryScore()+this.getmathematicsScore();
return total;
}
public float avarageScore()
{
float total=this.getenglishScore()+this.getcomputerScore()+this.gethistoryScore()+this.getmathematicsScore();
float avarage=total/4;
return avarage;
}
public float highScore()
{
float high;
if (this.getenglishScore()>this.getcomputerScore())
{
high=this.getenglishScore();
}else
{
high=this.getcomputerScore();
}
if (high<this.gethistoryScore())
{
high=gethistoryScore();
}
if (high<this.getmathematicsScore())
{
high=getmathematicsScore();
}
return high;
}
public float lowScore()
{
float low;
if (this.getenglishScore()<this.getcomputerScore())
{
low=this.getenglishScore();
}else
{
low=this.getcomputerScore();
}
if (low>this.gethistoryScore())
{
low=gethistoryScore();
}
if (low>this.getmathematicsScore())
{
low=getmathematicsScore();
}
return low;
}
public void PrintStudentInformation()
{
System.out.println("姓名:"+this.getname()+" 英语成绩:"+this.getenglishScore()+" 计算机成绩:"+this.getcomputerScore()+
" 历史成绩"+this.gethistoryScore()+" 数学成绩"+this.getmathematicsScore());
System.out.println("总成绩:"+this.totalScore()+"平均成绩:"+this.avarageScore()+"最高分:"+this.highScore()+"最低分:"+this.lowScore());
}
}
public class Hello{
public static void main(String arg[]){
Student student1=null;
student1=new Student("sun");
student1.setenglishScore(90.5f);
student1.setcomputerScore(93.5f);
student1.sethistoryScore(88.0f);
student1.setmathematicsScore(99.0f);
student1.PrintStudentInformation();
}
}