Answer to Question #213004 in C++ for Hemambar

Question #213004
Define a class Employee with data members as empno, name and designation. Derive a class Qualification from Employee that has data members UG, PG and experience. Create another class Salary which is derived from both these classes to display the details of the employee and compute their increments based on their experience and qualifications.
1
Expert's answer
2021-07-05T06:51:11-0400
#include <iostream>
#include <string>


using namespace std;




class Employee{
protected:
	string empno; 
	string name;
	string designation;
public:
	void get()
	{
		cout<<"Enter Employee No: ";
		getline(cin,empno);
		cout<<"Enter Employee Name: ";
		getline(cin,name);
		cout<<"Enter Employee Designation: ";
		getline(cin,designation);
	}
};
class Qualification :public Employee{
protected:
	int UG;
	int PG;
	int experience;
public:
	void get()
	{
		Employee::get();
		cout<<"Enter Employee UG: ";
		cin>>UG;
		cout<<"Enter Employee PG: ";
		cin>>PG;
		cout<<"Enter Employee Experience: ";
		cin>>experience;
	}
};
class Salary:public Qualification{
public:
	void get()
	{
		Qualification::get();
	}
	void displayDetailsEmployee(){
		cout<<"Employee No: "<<empno<<"\n";
		cout<<"Employee Name: "<<name<<"\n";
		cout<<"Employee Designation: "<<designation<<"\n";
		cout<<"Employee UG: "<<UG<<"\n";
		cout<<"Employee PG: "<<PG<<"\n";
		cout<<"Employee Experience: "<<experience<<"\n";
		int increments =UG+PG+experience;
		cout<<"Employee increments: "<<increments <<"\n";
		
	}
};




int main () {


	Salary salaryEmp;
	salaryEmp.get();
	salaryEmp.displayDetailsEmployee();
	//Delay
	system("pause");
	return 0;
}









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