Answer to Question #213136 in C++ for Hemambar

Question #213136

Create a class called Employee with protected data members emp_id, name and designation. It

contains the member functions to get details of employee and display them. Derive two classes

Permanent and Contract from Employee class. Contract has data members num_hrs and

wages_per_hr. Permanent has basic, DA, TA and HRA. Get the necessary details using member

functions and display the employee details with their salary according to the given data.


1
Expert's answer
2021-07-18T04:23:46-0400
#include<iostream>
using namespace std;
class Employee{
	protected:
		int  emp_id;
		string name;
		string designation;
	public:
		void Employee_details(){
			cout<<"Enter employee id\n";
			cin>>emp_id;
			cout<<"Enter employee name\n";
			cin>>name;
			cout<<"The employee designation\n";
			cin>>designation;
		}
		void display_details(){
	Employee_details();
			cout<<"The employee id is\t"<<emp_id;
			cout<<"The employee name is\t"<<name<<endl;
			cout<<"The employee designation is\t"<<designation<<endl;
		}
};
class Permanent: public Employee{
	private:
		double basic;
		double DA;
		double TA;
		double HRA;
	public:
		void input_permanet(){
			cout<<"Enter the employee basic \t\n";
			cin>>basic;
			cout<<"Enter the employee DA \n";
			cin>>DA;
			cout<<"Enter the employee TA\n";
			cin>>TA;
			cout<<"Enter the employee HRA\n";
			cin>>HRA;
		}
		void total_salary(){
			input_permanet();
			display_details();
			cout<<"Enter the employee basic \t"<<basic;
			
			cout<<"\nEnter the employee DA \t"<<DA;
			
			cout<<"\nEnter the employee TA\t"<<TA;
			
			cout<<"\nEnter the employee HRA\t"<<HRA;
			
			cout<<"\nThe salary for the employee is\t"<<basic + DA+TA+HRA<<endl;
		}
	
}; 
class Contract: public Employee{
	private:
		int  num_hrs;
		double wages_per_hr;
	public:
		void input_contract(){
			cout<<" employee number of hours\n";
			cin>>num_hrs;
			cout<<"Enter the employee wages per hour\n";
			cin>>wages_per_hr;
		}
	 void display_contract(){
	 	input_contract();
	 	display_details();
	 		cout<<"\nEnter the employee number of hours\t"<<num_hrs;
			cout<<"\nEnter the employee wages per hour\t"<<wages_per_hr;
	 	cout<<"\nThe employee salary is \t"<<num_hrs * wages_per_hr;
	 }
}; 

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
APPROVED BY CLIENTS