(+84) 236.3827111 ex. 402

Lập trinh hướng đối tượng: Quản lý học sinh


#include

#include

using namespace std;

class hocsinh{

private:

string ten;

string lop;

float toan, ly,hoa,dtb;

public:

hocsinh(string ht=" ", string lh=" ",float t=0, float l=0, float h=0);

void nhap();

void xuat();

void dtbhon5();

};

hocsinh::hocsinh(string ht, string lh, float t, float l, float h){

this->ten=ht;

this->lop=lh;

this->toan=t;

this->ly=l;

this->hoa=h;

}

void hocsinh::nhap(){

cout<<"Nhap ho ten: "; getline(cin,ten);

cout<<"Nhap ten lop: ";getline(cin,lop);

cout<<"Nhap diem toan: ",cin>>toan;

cout<<"Nhap diem ly: ";cin>>ly;

cout<<"Nhap diem hoa: ";cin>>hoa;

dtb=(toan+ly+hoa)/3;

}

void hocsinh::xuat(){

cout<<"Hoc sinh: "<

cout<<"Diem toan: "<<>

cout<<" Diem hoa: "<<><>

}

void hocsinh::dtbhon5(){

if(dtb>=5){

cout<<"Hoc sinh: "<

cout<<"Diem toan: "<<>

cout<<" Diem hoa: "<<><>

}

}

int main(){

int n;

hocsinh *hs;

cout<<"Nhap danh sach hoc sinh: ";cin>>n;

hs=new hocsinh[n];

for(int i=0;i<>

hs[i].nhap();

cout<<>

for(int i=0;i<>

hs[i].xuat();

cout<=5:"<<>

for(int i=0;i<>

hs[i].dtbhon5();

delete[] hs;

return0;

}