Answer to Question #174153 in C++ for Rahul

Question #174153

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-26T12:38:58-0400
#include <iostream>
#include <string>




using namespace std;


class Person 
{
public:
	Person(){}
	Person(string name,int age){
		this->name=name;
		this->age=age;
	}
protected:
	string name;
	int age;
};
class Salary:public Person
{
public:
	Salary(){}
	Salary(string name,int age,double salary):Person(name,age){
		this->salary=salary;
	}
protected:
	float salary;
};
class Employee:public Salary
{
public:
	Employee(){}
	Employee(string name,int age,double salary,int degree,int experience):Salary(name,age,salary){
		this->degree=degree;
		this->experience=experience;
	}
protected:
	int degree;
	int experience;
};


class Manager:public Employee
{
public:
	Manager(){}
	Manager(string name,int age,double salary,int degree,int experience):Employee(name,age,salary,degree,experience){}
	
	void pfund(){
		double pf=750;
		if(salary>20000.0 && experience>10){
			pf=1800;
		}
		double netSalary=salary + pf;
		cout<<"Name: "<<name<<endl;
		cout<<"Age: "<<age<<endl;
		cout<<"Salary: Rs. "<<salary<<endl;
		cout<<"Degree: "<<degree<<endl;
		cout<<"Experience: "<<experience<<endl;
		cout<<"Net salary: Rs. "<<netSalary<<endl;
	}
};




int main(){
	Manager Mary("Mary",25,60000,9,15);
	Mary.pfund();
	cout<<endl;
	Manager Mike("Mike",35,600,5,5);
	Mike.pfund();
	cout<<endl;
	Manager John("John",30,75000,10,5);
	John.pfund();


	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