Answer to Question #284300 in C++ for amna

Question #284300

An organization has two types of employees: regular and adhoc. Regular employees get a salary which is basic + DA + HRA where DA is 10% of basic and HRA is 30% of basic. Adhoc employees are daily wagers who get a salary which is equal to Number * Wage.

Define the constructors. When a regular employee is created, basic must be a parameter. When adhoc employee is created wage must be a parameter. (iii) Define the destructors. (iv)Define the member functions for each class. The member function days ( ) updates number of the Adhoc employee. (v) Write a test program to test the classes


1
Expert's answer
2022-01-02T08:17:00-0500
#include <iostream>
using namespace std;
class Regular{
    float basic;
    float DA;
    float HRA;
    float salary;


    public:
        Regular(float sal): basic(sal){
            DA = 0.1 * basic;
            HRA = 0.3 * basic;
            salary = DA + HRA + basic;
        }
        float getSalary(){
            return salary;
        }
        ~Regular(){}
};
class Adhoc{
    int number;
    float wage;


    public:
        Adhoc(float wag): wage(wag){
            
        }
        void days(int n){
            number = n;
        }
        float getSalary(){
            return number * wage;
        }
        ~Adhoc(){}
};


int main(){
    Regular empl1(2000);
    Adhoc empl2(200);


    empl2.days(2);


    cout<<"Salary of regular: "<<empl1.getSalary();
    cout<<"\nSalary of adhoc: "<<empl2.getSalary();


    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