Answer to Question #174864 in C++ for Vijay Raj

Question #174864

Develop a code for the hybrid Inheritance diagram given below

·         The employee details class consisting of data members such as name and emp_id.

·         The normal pay class consisting of data members such as basic salary.

·         The additional pay class consisting of data members such as hours, rupees and additional pay.

·         The net pay class consisting of member function cal() to find the employee total salary = additional pay + basic salary. 

(  Reusability using inheritance )


1
Expert's answer
2021-03-23T14:00:12-0400
 
#include<iostream>
using namespace std;
class employee
{
    protected:
    char name;
    int emp_id;
    public:
    void get_name();
    void get_emp_id()
    {
        cout<<"Enter the name of the employee:"<<endl;
        cin>>name;
        cout<<"Enter the emp_id of the employee:"<<endl;
        cin>>emp_id;
    }
};
class normal_pay: public employee
{
    protected:
    double basic_salary;
    public:
    void get_basic_salary()
    {
        cout<<"Enter the basic salary:"<<endl;
        cin>>basic_salary;
    }
};
class additional_pay
{
    protected:
    int hours;
    int rupees;
    int additional_pay;
    public:
    void get_hours();
    void get_rupees();
    void get_additional_pay()
    {
        cout<<"Enter hours rupees and additional pay:"<<endl;
        cin>>hours>>rupees>>additional_pay;
    }
};
class netpay : public normal_pay , public additional_pay
{
    protected:
    int total_salary;
    public:
    void total()
    {
        get_additional_pay();
        get_basic_salary();
        cout<<"total salary: "<<basic_salary + additional_pay<<endl;
    }
};
int main(){
    netpay total_salary;
    total_salary.total();
    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