0% found this document useful (0 votes)
61 views9 pages

C++ Class Structure for Employee Management

The document contains C++ code that defines classes for managing employee information. There are base classes like CanBo that define common properties like name, date of birth, address, gender. Derived classes like CongNhan, KySu, NhanVienPhucVu add additional properties specific to each employee type. A QLCB class contains menu options to search employees by name or display the employee list. The main function initializes arrays of each employee type, gets user input to select an employee type and number, then collects input to populate employee objects of the selected type.

Uploaded by

Tú Diệp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views9 pages

C++ Class Structure for Employee Management

The document contains C++ code that defines classes for managing employee information. There are base classes like CanBo that define common properties like name, date of birth, address, gender. Derived classes like CongNhan, KySu, NhanVienPhucVu add additional properties specific to each employee type. A QLCB class contains menu options to search employees by name or display the employee list. The main function initializes arrays of each employee type, gets user input to select an employee type and number, then collects input to populate employee objects of the selected type.

Uploaded by

Tú Diệp
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include<iostream>

#include<conio.h>
#include<string>
using namespace std;
class canbo
{
protected: string hoten, namsinh, diachi,gioitinh;
public:
void nhapthongtin()
{
cout << "Nhap ho ten";
[Link]();
getline(std::cin, hoten);
cout << "Nhap nam sinh";
[Link]();
getline(std::cin, namsinh);
cout << "Nhap gioi tinh";
[Link]();
getline(std::cin, gioitinh);
cout << "Nhap dia chi";
[Link]();
getline(std::cin, diachi);
}
};
class congnhan :public canbo
{
protected: string capbac;
public:
void nhapcapbac()
{
cout << "Nhap cap bac cua cong nhan";
[Link]();
getline(std::cin, capbac);
}
};
class kysu :public canbo
{
protected:string nganhdaotao;
public:
void nhapnganhdaotao()
{
cout << "Nhap nganh dao tao :";
[Link]();
getline(std::cin, nganhdaotao);
}
};
class nhanvienphucvu:public canbo
{
protected:string congviec;
public:
void nhapcongviec()
{
cout << "Nhap cong viec:";
[Link]();
getline(std::cin, congviec);
}
};
class QLCB
{
private:
string ht;
int traloi,doituong;
public:
int menu()
{
cout << "\nHay chon 1 trong 3 chuc nang:" << endl;
cout << "1)Tim kiem theo ho ten" << endl;
cout << "2)Hien thi thong tin danh sach can bo" << endl;
cout << "3) Thoat" << endl;
cin>>traloi;
while (traloi < 0 || traloi>3)
{
cout << " So ban nhap khong hop le" << endl;
cout << "Vui long nhap so khac" << endl;
cin >> traloi;
}
return traloi;
}
int chondoituong()
{
cout << "\nDoi tuong ban chon lam gi?"<<endl;
cout << "1) cong nhan" << endl;
cout << "2) Ky su" << endl;
cout << "3) Nhan vien phuc vu" << endl;
cin>>doituong;
while (doituong < 0 || doituong>3)
{
cout << " So ban nhap khong hop le" << endl;
cout << "Vui long nhap so khac" << endl;
cin >> doituong;
}
return doituong;
}
};
int main()
{
QLCB s[10];
congnhan a[10];
kysu k[10];
nhanvienphucvu p[10];
int l,n,i;
string hoten2;
l = s[10].chondoituong();
cout << "Nhap so n ";
cin >> n;
s[10].chondoituong();
for (i = 0; i < n; i++)
{
if (l == 1)
{
a[i].nhapthongtin();
a[i].nhapcapbac();
}
if (l == 2)
{
k[i].nhapthongtin();
k[i].nhapnganhdaotao();
}
if (l == 3)
{
p[i].nhapthongtin();
p[i].nhapcongviec();
}
}
_getch();
return 0;
}
Bài cái bàn

#include<iostream>
#include<conio.h>
using namespace std;
class luachon
{
protected: int mausac, hinhdang, vatlieu;
public:
void chonhinhdang()
{
cout << "\n Hay chon hinh dang ban muon:"<<endl;
cout << "1) Hinh chu nhat" << endl;
cout << "2) Hinh vuong" << endl;
cout << "3)Hinh tron" << endl;
cin >> hinhdang;
while (hinhdang < 0 || hinhdang>3)
{
cout << " So ban nhap khong hop le" << endl;
cout << "Vui long nhap sai" << endl;
cin >> hinhdang;
}
}
void chonvatlieu()
{
cout << "\n Hay chon vat lieu ma ban muon"<<endl;
cout << "1) Nhua" << endl;
cout << "2) Sat" << endl;
cout << "3) Go" << endl;
cin >> vatlieu;
while (vatlieu < 0 || vatlieu>3)
{
cout << " So ban nhap khong hop le" << endl;
cout << "Vui long nhap sai" << endl;
cin >> vatlieu;
}
}
void chonmausac()
{
cout << "\n Hay chon mau sac ma ban muon"<<endl;
cout << "1) Den" << endl;
cout << "2) Nau" << endl;
cout << "3) Xam" << endl;
cin >> mausac;
while (mausac < 0 || mausac >3)
{
cout << " So ban nhap khong hop le" << endl;
cout << "Vui long nhap sai" << endl;
cin >> mausac;
}
}
};
class solieu :public luachon
{
protected:
float chieudai, chieurong, chieucao, bankinh,canh;
public:
void nhapsolieu()
{
if (hinhdang == 1)
{
cout << "Nhap chieu dai :";
cin >> chieudai;
cout << "Nhap chieu rong:";
cin >> chieurong;
cout << "Nhap chieu cao";
cin >> chieucao;
while (chieudai <= 0 || chieurong <= 0 || chieucao <= 0)
{
cout << "Ban nhap gia tri khong hop le" << endl;
cout << "vui long nhap lai so khac" << endl;
cin >> chieudai >> chieurong >> chieucao;
}
}
if (hinhdang == 2)
{
cout << "Nhap canh cua ban:";
cin >> canh;
cout << "Nhap chieu cao";
cin >> chieucao;
while (canh <= 0||chieucao<=0)
{
cout << "Ban nhap gia tri khong hop le" << endl;
cout << "vui long nhap lai so khac" << endl;
cin >> canh >>chieucao;
}
}
if (hinhdang == 3)
{
cout << "Nhap ban kinh hinh tron:";
cin >> bankinh;
cout << "Nhap chieu cao";
cin >> chieucao;
while (bankinh <= 0 || chieucao <= 0)
{
cout << "Ban nhap gia tri khong hop le" << endl;
cout << "vui long nhap lai so khac" << endl;
cin >> bankinh >> chieucao;
}
}
}
};
class caiban:public solieu
{
private:float thetich;
public:
void thetichban()
{
if (hinhdang == 1)
{
thetich = chieudai*chieurong*chieucao;
cout << "The tich cua cai ban la:" << thetich << endl;
}
if (hinhdang == 2)
{
thetich = canh*canh*chieucao;
cout << "The tich cua cai ban la:" << thetich << endl;
}
if (hinhdang == 3)
{
thetich = bankinh*chieucao*bankinh*3.14;
cout << "The tich cua cai ban la:" << thetich << endl;
}
}
};
int main()
{
caiban s[10];
int n, i;
cout << "Nhap so luong ban ma ban muon:";
cin >> n;
for (i = 0; i < n; i++)
{
s[i].chonhinhdang();
s[i].chonmausac();
s[i].chonvatlieu();
s[i].nhapsolieu();
s[i].thetichban();
}
_getch();
return 0;
}
----------------------------------------------------------------------------------------------------

Bài doanh thu

include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class thu
{
private:
long tienthutuan1, tienthutuan2, tienthutuan3, tienthutuan4, tienthutuan5;
long tongthu;
public:
void Nhaptienthu()
{
cout << "Tien thu duoc trong tuan 1 la: ";
cin >> tienthutuan1;
cout << "Tien thu duoc trong tuan 2 la: ";
cin >> tienthutuan2;
cout << "Tien thu duoc trong tuan 3 la: ";
cin >> tienthutuan3;
cout << "Tien thu duoc trong tuan 4 la: ";
cin >> tienthutuan4;
cout << "Tien thu duoc trong tuan 5 la: ";
cin >> tienthutuan5;
}
long Tongthu()
{
tongthu = tienthutuan1 + tienthutuan2 + tienthutuan3 + tienthutuan4 + tienthutuan5;
return tongthu;
}
};
class chi
{
private:
long tiennguyenlieu, tienthuematbang, tiennuoc, tiendien, tiennhanvienbanduoc, thuong,
chiphiphatsinh;
long tongchi1, tongluong;
long tienluong;
string hoten;
int i, n;
public:
void Nhaptienchi()
{
cout << "Nhap tien nguyen lieu da mua ";
cin >> tiennguyenlieu;
cout << "Nhap tien mat bang: ";
cin >> tienthuematbang;
cout << "Nhap tien nuoc: ";
cin >> tiennuoc;
cout << "Nhap tien dien: ";
cin >> tiendien;
cout << "Nhap chi phi phat sinh: ";
cin >> chiphiphatsinh;
}

long Tongchi1()
{
tongchi1 = tiennguyenlieu + tiennuoc + tiendien + chiphiphatsinh + tienthuematbang;
return tongchi1;
}
};
class nhanvien
{
private:long tiennhanvienbanduoc, tongluong, tienluong,thuong;
string hoten;
int n,i;
public:
long Tienluongnhanvien()
{
long tongluong = 0;
cout << "Nhap so nhan vien :";
cin >> n;
for (i = 0; i < n; i++)
{
cout << "Nhap ho ten nhan vien: ";
[Link]();
getline(std::cin, hoten);
cout << "Nhap tien nhan vien nay ban duoc: ";
cin >> tiennhanvienbanduoc;
if (tiennhanvienbanduoc > 2500000)
{
thuong = 0.1*tiennhanvienbanduoc;
cout << "Tien thuong nhan vien la " << thuong << endl;
}
else
{
thuong = 0;
cout << "Nhan vien nay khong duoc thuong" << endl;
}
cout << "Tien luong 1 nhan vien la 420000/1 thang chua tinh thuong " << endl;
tienluong = 4200000 + thuong;
cout << "Tien luong nhan vien nay la: " << tienluong << endl;
tongluong = tongluong + tienluong;
}
return tongluong;
}
};
int main()
{
long doanhthuquantrasua;
thu t;
chi c;
nhanvien nv;
long tongluong;
[Link]();
[Link]();
[Link]();
tongluong = [Link]();
long chi;
long thu;
chi = c.Tongchi1();
thu = [Link]();
cout << "Tong thu cua quan la: " << thu << endl;
cout << "Tong chi cua quan la: " << chi << endl;
cout << "Tong luong nhan vien la:" << tongluong << endl;
doanhthuquantrasua = thu - (chi+tongluong);
cout << "Doanh thu cua quan trong 1 thang la: " << doanhthuquantrasua << endl;
if (doanhthuquantrasua > 10000000) cout << "Doanh thu quan dat yeu cau " << endl;
else cout << "Doanh thu quan khong dat yeu cau " << endl;
_getch();
return 0;
}

Bài MBI

#include<iostream>
#include<conio.h>
#include<string>
using namespace std;
class TINHMBI
{
private:
float cc; float cn; float MBI; string hoten;
public:
void Nhaphoten()
{
cout << "Nhap ho ten:";
getline(cin,hoten);
}
void chieucao()
{
cout << "Nhap chieu cao cua ban:";
cin >> cc;
}
void cannang()
{
cout << "Nhap can nang cua ban:";
cin >> cn;
}
void tinhMBI()
{
MBI = cn / (cc*cc);
}
void xuat()
{
if (MBI <= 18.5)
{
cout << "Ban co than hinh gay" << endl;
}
else if (18.5 < MBI && MBI <= 25)
{
cout << "Ban co than hinh can doi" << endl;
}
else if (MBI <= 30)
{
cout << "Ban bi beo phi" << endl;
}
else
{
cout << "Ban bi beo [Link] nen giam can"<<endl;
}
}
};
int main()
{
TINHMBI ketqua1;
TINHMBI ketqua2;
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
[Link]();
_getch();
return 0;
}

You might also like