Answer to Question #174187 in C++ for Harini.M

Question #174187

Develop a code for the multilevel inheritance diagram given below

·         The person class consisting of data members such as name and age.

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

·         The employee class consisting of data members such as degree and experience.

·         The manager class consisting of member function pfund() to find the employee provident fund satisfying the condition total experience to be greater than 10 and salary to be greater than Rs. 20,000 and then calculate net salary = basic pay + pf. The provident fund amount sanctioned is Rs. 1800 for basic pay Rs 20,000 otherwise provident fund amount sanctioned is Rs. 750



1
Expert's answer
2021-03-28T00:24:54-0400
#include <iostream>
#include <string>


class Person 
{
private:
	//The person class consisting of data members such as name and age.
	std::string name;
	int age;
public:
	Person(){}
	void setName(std::string name){
		this->name=name;
	}
	std::string getName(){
		return this->name;
	}
	void setAge(int age){
		this->age=age;
	}
	int getAge(){
		return this->age;
	}
};
class Salary:public Person
{
private:
	//The salary details class consisting of data members such as salary.
	float salary;
public:
	Salary(){}
	void setSalary(float salary){
		this->salary=salary;
	}
	float getSalary(){
		return this->salary;
	}
};
class Employee:public Salary
{
private:
	// The employee class consisting of data members such as degree and experience.
	int degree;
	int experience;
public:
	Employee(){}
	void setDegree(int degree){
		this->degree=degree;
	}
	int getDegree(){
		return degree;
	}
	void setExperience(int experience){
		this->experience=experience;
	}
	int getExperience(){
		return this->experience;
	}
};


class Manager:public Employee
{
public:
	
	Manager(){}
	// The manager class consisting of member function pfund() to find the employee provident fund satisfying the 
	//condition total experience to be greater than 10 and salary to be greater than Rs. 20,000 and then calculate net salary = basic pay + pf. 
	//The provident fund amount sanctioned is Rs. 1800 for basic pay Rs 20,000 otherwise provident fund amount sanctioned is Rs. 750
	void pfund(){
		if(getSalary()>20000.0 && getExperience()>10){
			float netSalary=getSalary() + 1800;
			std::cout<<"Manager name: "<<getName()<<"\n";
			std::cout<<"Manager age: "<<getAge()<<"\n";
			std::cout<<"Manager salary: "<<getSalary()<<"\n";
			std::cout<<"Manager degree: "<<getDegree()<<"\n";
			std::cout<<"Manager experience: "<<getExperience()<<"\n";
			std::cout<<"Manager net salary: "<<netSalary<<"\n\n";
		}else{
			float netSalary=getSalary() + 750;
			std::cout<<"Manager name: "<<getName()<<"\n";
			std::cout<<"Manager age: "<<getAge()<<"\n";
			std::cout<<"Manager salary: "<<getSalary()<<"\n";
			std::cout<<"Manager degree: "<<getDegree()<<"\n";
			std::cout<<"Manager experience: "<<getExperience()<<"\n";
			std::cout<<"Manager net salary: "<<netSalary<<"\n\n";
		}
	}
};




int main(){
	Manager Phillips;
	Phillips.setName("Phillips");
	Phillips.setAge(40);
	Phillips.setSalary(55000);
	Phillips.setDegree(11);
	Phillips.setExperience(15);
	Phillips.pfund();


	Manager Evans;
	Evans.setName("Evans");
	Evans.setAge(48);
	Evans.setSalary(85000);
	Evans.setDegree(6);
	Evans.setExperience(9);
	Evans.pfund();
	


	Manager Reed;
	Reed.setName("Reed");
	Reed.setAge(19);
	Reed.setSalary(32000);
	Reed.setDegree(12);
	Reed.setExperience(8);
	Reed.pfund();
	int delay;
	std::cin>>delay;
	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