Answer to Question #294592 in C++ for Francislebabu

Question #294592

A company has both part time and full time employees. The details of full-time employees include name department contacts basic pay and part time employees Inherit some properties of full time employees calculate their basic pay and basic details

1
Expert's answer
2022-02-07T05:10:36-0500
#include<iostream>
#include<string>

using namespace std;

class FullTimeEmpl
{
	string EmplName;
	string nameDep;
	double basPay;
public:
	//default constructor
	FullTimeEmpl(){}
	//Parametrized constructor
	FullTimeEmpl(string _EmplName, string _nameDep,	double _basPay)
	:EmplName(_EmplName),nameDep(_nameDep),basPay(_basPay){	}
	void SetData()
	{
		cout<<"Please, enter an employer name: ";
		cin>>EmplName;
		cout<<"Please, enter a name department contacts: ";
		cin.ignore(256,'\n');
		getline(cin,nameDep,'\n');	
	}
	void SetBasPay()
	{
		cout<<"Please, enter a basic pay for full time employee: ";
		cin>>basPay;
	}
			
	string GetEmplName(){return EmplName;}
	string GetNameDep(){return nameDep;}
	double GetBasPay(){return basPay;}
	
	void FDisplay()
	{
		cout<<"\nEmployee name is "<<EmplName;
		cout<<"\nName department contacts are "<<nameDep;
		cout<<"\nBasic full time employee`s pay is "<<basPay;
	}
};

class PartTimeEmpl:public FullTimeEmpl
{
	double basPayPartEmpl;	
public:
	//default constructor
	PartTimeEmpl(){}
	//Parametrized constructor
	//Consider on default, that part time employers have basPayPartEmpl as 0.75*basPay
	PartTimeEmpl(string _EmplName, string _nameDep,	double _basPay)
	:FullTimeEmpl(_EmplName,_nameDep,_basPay)
	{
		//Consider on default, that part time employers have basPayPartEmpl as 0.75*basPay
		basPayPartEmpl=0.75*_basPay;
	}
	void SetBasPayPartEmpl()
	{
		cout<<"Please, enter a basic pay for part time employee: ";
		cin>>basPayPartEmpl;
	}
	void PDisplay()
	{
		cout<<"\nEmployee name is "<<GetEmplName();
		cout<<"\nName department contacts are "<<GetNameDep();
		cout<<"\nBasic part time employee`s pay is "<<basPayPartEmpl;
	}
};

int main()
{
	FullTimeEmpl ft1("John","Financial department",3000);
	FullTimeEmpl ft2;
	ft2.SetData();
	ft2.SetBasPay();
	PartTimeEmpl pt1("Wasley","Financial department",3000);
	PartTimeEmpl pt2;
	pt2.SetData();
	pt2.SetBasPayPartEmpl();
	
	ft1.FDisplay();
	ft2.FDisplay();
	pt1.PDisplay();
	pt2.PDisplay();
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog