ssss
unknown
abap
3 years ago
1.4 kB
6
Indexable
#include <iostream> #include <iomanip> using namespace std; class sv{ string ten,xl; float dt,dv,dtb; public: sv(string ten,float dv,float dt) { this->ten=ten; this->dv=dv; this->dt=dt; }; string getName(){ return ten; } float getToan(){ return dt; } float getVan(){ return dv; } sv(sv & sv1){ this->ten=sv1.ten; this->dv=sv1.dv; this->dt=sv1.dt; this->xl=sv1.xl; this->dtb=sv1.dtb; } ~sv(){ delete this; } void nhap(){ cin>>this->ten; cin>>this->dt; cin>>this->dv; } void setName(string ten){ this->ten = ten; } void setToan(float dt){ this->dt=dt; } void setVan(float dv){ this->dv=dv; } float setDTB(){ this->dtb=(dv+dt)/2; return this->dtb; } string setXL(){ if(setDTB()>=8) xl= "Gioi"; else if(setDTB()>=7) xl= "Kha"; else if(setDTB()>=5) xl= "Trung binh"; else xl= "Yeu"; return xl; } void xuat(){ setXL(); cout<<setw(20)<<ten<<setw(20)<<dv<<setw(20)<<dt<<setw(20)<<dtb<<setw(20)<<xl<<endl; } }; int main(){ sv sv1("Le Van Tu",9,10); sv1.setToan(9.5); sv1.xuat(); }
Editor is loading...