HaDuyAnh Bai3
#include <iostream.h>
#include <conio.h>
#include <string.h>
#include <stdio.h>
#include <iomanip.h>
class NHANSU
{
protected:
char hoten[30],gtinh[5];
int nsinh;
};
//------------
class CANBO: public NHANSU
{
char phongban[10],diachi[10];
float hsluong,hspcap,giamtru;
public:
void nhap();
void xuat();
float TCKT();
};
float CANBO::TCKT()
{
float thunhap=450000*(hsluong+hspcap)-giamtru;
return thunhap;
}
//-------------
void CANBO::nhap()
{
cout<<"Nhap ho ten: ";
gets(NHANSU::hoten);
fflush(stdin);
cout<<"Nhap nam sinh: ";
cin>>NHANSU::nsinh;
cout<<"Nhap gioi tinh: ";
gets(NHANSU::gtinh);
fflush(stdin);
cout<<"Nhap phong ban: ";
gets(phongban);
cout<<"Nhap dia chi: ";
gets(diachi);
cout<<"Nhap he so luong";
cin>>hsluong;
cout<<"Nhap he so phu cap";
cin>>hspcap;
cout<<"Nhap giam tru:";
cin>>giamtru;
}
//-------------
void CANBO::xuat()
{
float thunhap=TCKT();
cout<<NHANSU::hoten<<setw(20)<<NHANSU::nsinh<<setw(20)<<NHANSU::gtinh<<endl;
cout<<phongban<<setw(20)<<diachi<<setw(20)<<hsluong<<setw(20)<<hspcap<<endl;
cout<<giamtru<<setw(20)<<thunhap<<endl;
cout<<"Nguoi tiep theo la: "<<endl;
}
//----------------
void main()
{
clrscr();
CANBO a[50];
int n;
cout<<"Nhap so can bo";
cin>>n;
for(int i=0;i<n;i++)
a[i].nhap();
cout<<" Danh sach vua nhap la:"<<endl;
for(i=0;i<n;i++)
a[i].xuat();
getch();
}
Bạn đang đọc truyện trên: Truyen247.Pro