//base class Employee
//class Permanent and Temporary derived from base class Employee
//class Contract and Daily Wages derived from class Temporary
//with parameterized constructor to initialize data members
//Employee: Name, Address
//Permanent: ID, basic_salary, grade, insurance_amount, p_fund
//Temporary: TempEmpID
//Contract: Salary, contract_start_date, contract_last_date
//Daily Wages: rate_per_day
#include <iostream>
#include <string.h>
using namespace std;
class Employee
{
protected:
char Name[30],Address[30];
public:
Employee(char n[],char a[])
{
strcpy(Name,n);
strcpy(Address,a);
}
DisplayEmployee()
{
cout<<endl<<"Name: "<<Name;
cout<<endl<<"Address: "<<Address;
}
};
class Permanent:public Employee
{
protected:
int ID,grade; //ID < 100
float basic_salary, insurance_amount, p_fund;
public:
Permanent(char n[], char a[], int i, float b_s, int g, float i_a, float p_f):Employee(n,a)
{
ID=i;
basic_salary=b_s;
grade=g;
insurance_amount=i_a;
p_fund=p_f;
}
DisplayPermanent()
{
cout<<endl<<"ID: "<<ID;
cout<<endl<<"Basic Salary: "<<basic_salary;
cout<<endl<<"Grade: "<<grade;
cout<<endl<<"Insurance Amount: "<<insurance_amount;
cout<<endl<<"Provident Fund: "<<p_fund;
}
};
class Temporary:public Employee
{
protected:
int TempEmpID; //>=100
public:
Temporary(char n[], char a[], int ti):Employee(n,a)
{
TempEmpID=ti;
}
DisplayTemporary()
{
cout<<endl<<"Temporary Employee ID: "<<TempEmpID;
}
};
class Contract:public Temporary
{
protected:
float Salary;
int contract_start_date, contract_last_date;
public:
Contract(char n[], char a[], int ti, float s, int cs, int cl):Temporary(n,a,ti)
{
Salary=s;
contract_start_date=cs;
contract_last_date=cl;
}
DisplayContract()
{
cout<<endl<<"Salary: "<<Salary;
cout<<endl<<"Contract Start Date: "<<contract_start_date;
cout<<endl<<"Contract Last Date: "<<contract_last_date;
}
};
class DailyWages:public Temporary
{
protected:
float rate_per_day;
public:
DailyWages(char n[], char a[], int ti, float r):Temporary(n,a,ti)
{
rate_per_day=r;
}
DisplayDailyWages()
{
cout<<endl<<"Rate Per Day: "<<rate_per_day;
}
};
int main()
{
Permanent p("Ram Hari Dhungel","Kalimati, Kathmandu",1,22000.00,7,2200.00,1100.00);
Contract c("Shiva Dahal","Gaushala, Kathmandu",100,300000.00,2017,2018);
DailyWages d("Ram Babu Deula","Sankhamul, Kathmandu",150,200);
cout<<"Displaying Permanent Staff:";
p.DisplayEmployee();
p.DisplayPermanent();
cout<<endl<<endl<<"Displaying Contract Staff:";
c.DisplayEmployee();
c.DisplayTemporary();
c.DisplayContract();
cout<<endl<<endl<<"Displaying Daily Wages Staff:";
d.DisplayEmployee();
d.DisplayTemporary();
d.DisplayDailyWages();
return 0;
}
No comments:
Post a Comment