Vous êtes sur la page 1sur 3

public class sinhvien{ private String name; private float toan; private float li; private float hoa;

public sinhvien(){ name = ""; toan=0; li=0; hoa=0; }

public sinhvien(sinhvien a) { name=a.name; toan=a.toan; li=a.li; hoa=a.hoa; }

public void setname(String nm) { name=nm; } public String getname()

{ return name; }

public void setscore(int mon,float diem) { if(mon==1) toan=diem; else if(mon==2) li=diem; else hoa=diem; }

public void setscore(float diem1,float diem2,float diem3) { toan=diem1; li=diem2; hoa=diem3; }

public float getscore(int mon) { if(mon==1) return toan; else if(mon==2) return li; else return hoa; }

public float getAverage() { float average; average = (toan+li+hoa)/3; return average; }

public float gethighscore() { float highscore; highscore=toan; if(li>highscore) highscore=li; if(hoa>highscore) highscore=hoa; return highscore; }

public String tostring() { return String.format("Name: %s \nToan: %.1f Li: %.1f Hoa: %.1f Trung Binh: %.1f",name,toan,li,hoa,getAverage()); } }

Vous aimerez peut-être aussi