Answer to Question #174886 in C++ for Kaviyan P

Question #174886

Develop a code for the multiple inheritance diagram given below


· The experience details class consisting of data members such as name and total experience.


· The salary details class consisting of data members such as salary.


· The education details class consisting of data members such as degree.


· The promotion class consisting of member function promote() to find the employee promotion for higher grade on satisfying the condition total experience to be greater than 10 and salary to be greater than Rs. 20,000 and the degree qualification to be “PG”, print "PROMOTED FOR HIGHER GRADE". otherwise the employee is not eligible for promotion, print "PROMOTION IS NOT ELIGIBLE


1
Expert's answer
2021-03-28T08:05:38-0400
#include <iostream>
#include <string>
 
using namespace std;
 
class Experience
{
public:
	Experience(string name_, int experience_)
	{
		name = name_;
		experience = experience_;
	}
protected:
	string name;
	int experience;
};
 
class Salary
{
public:
	Salary(double salary_) { salary = salary_; }
protected:
	double salary;
};
 
class Education
{
public:
	Education(string education_) { education = education_; }
protected:
	string education;
};
 
class Promotion : public Experience, public Salary, public Education
{
public:
	Promotion(string name_, int experience_, double salary_, string education_);
	void promote();
};
 
Promotion::Promotion(string name_, int experience_, double salary_, string education_) : Experience(name_, experience_), Salary(salary_), Education(education_)
{}
 
void Promotion::promote()
{
	if (experience > 10 && salary > 20000 && education == "PG") cout << "PROMOTED FOR HIGHER GRADE" << endl;
	else cout << "PROMOTION IS NOT ELIGIBLE" << endl;
}
 
int main()
{
	string name;
	int expirience = 0;
	double salary = 0;
	string degree;
 
	cout << "Enter name: ";
	cin >> name;
	cout << "Enter expirience: ";
	cin >> expirience;
	cout << "Enter salary: ";
	cin >> salary;
	cout << "Enter degree: ";
	cin >> degree;
 
	Promotion Temp(name, expirience, salary, degree);
	Temp.promote();
	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