Answer to Question #235930 in C++ for gikovi

Question #235930

Create a class which stores employee name, id and salary. Derive two classes from ‘Employee’ class: ‘Regular’ and ‘Part-Time’. The ‘Regular’ class stores DA, HRA and basic salary, which is to be given during the run-time. The ‘Part-Time’ class stores the number of hours and pay per hour, which is also to be given during the run-time. Calculate the salary of a regular employee and a part-time employee. 


1
Expert's answer
2021-09-11T23:39:50-0400
#include <iostream>


using namespace std;


class Employee{
    protected:
        string name;
        int id;
        double salary;
    public:
    
};


class Regular: public Employee{
    private:
        double DA;
        double HRA;
        double basic_salary;
    public:
     Regular(double d, double h, double b){
         DA=d;
         HRA=h;
         basic_salary=b;
     }
     void display(){
            cout<<"\nSalary of the Regular employee is "<<(DA+HRA+basic_salary);
        }
    
};


class PartTime: public Employee{
    private:
        int number_of_hours;
        double pay_per_hour;
    public:
        PartTime(int n, double p){
            number_of_hours=n;
            pay_per_hour=p;
        }
        void display(){
            cout<<"\nSalary of the part-time employee is "<<(number_of_hours*pay_per_hour);
        }
};


int main()
{
    Regular r(2000,3000,10000);
    r.display();
    
    PartTime p(8,800);
    p.display();


    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

gikovi
12.09.21, 11:22

Thank you so much AssignmentExpert !!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS