Answer to Question #213179 in C++ for Hemambar

Question #213179

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-21T16:46:58-0400
#include <iostream>
#include <string>
using namespace std;
class Employee{
protected:
	string empno; 
	string name;
	string designation;
public:
	void input()
	{
		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 input_qualification()
	{
		input();
		cout<<"Enter Employee UG: ";
		cin>>UG;
		cout<<"Enter Employee PG: ";
		cin>>PG;
		cout<<"Enter Employee Experience: ";
		cin>>experience;
	}
};
class Salary:public Qualification{
private:
	int increments;
public:
	void input_salary()
	{
		input_qualification();
		increments=UG+PG+experience;
	}
	void display(){
		
		cout<<"No: "<<empno<<"\n";
		cout<<"Name: "<<name<<"\n";
		cout<<"Designation: "<<designation<<"\n";
		cout<<"UG: "<<UG<<"\n";
		cout<<"PG: "<<PG<<"\n";
		cout<<"Experience: "<<experience<<"\n";
		cout<<"Increments: "<<increments <<"\n";
		
	}
};
int main () {
	Salary salaryEmployee;
	salaryEmployee.input_salary();
	salaryEmployee.display();
	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