Answer to Question #202042 in C++ for zain ul abdeen

Question #202042

Question #198286

Using graphical user interface.

We want to design a system for a company to calculate salaries of different types of employees. 


https://ibb.co/swS948B


Every employee has an employee ID and a basic salary. The Commissioned employee has a sales amount and rate. Hourly employee is paid on the basis of number of working hours. A regular employee may have a bonus. You have to implement all the above classes. Write constructor for all classes. The main functionality is to calculate salary for each employee which is calculated as follows: Commissioned Employee: Total Salary=sales amount*rate/100+basic salary Hourly Employee: Total salary=basic salary + pay per hour*extra hours Regular Employee: Total salary= basic salary + bonus You have to define the following function in all classes: float calculateSalary() and run the given main() for the following two cases: 1. when the calculateSalary() in base class is not virtual


2. when the calculateSalary() in base class is made virtual


1
Expert's answer
2021-06-04T06:04:45-0400


#include <iostream>
using namespace std;


class Employee{
    protected:
        int emp_id;
        float basic_salary;
    public:
        Employee(){
            
        }
        float calculateSalary(){
            
        }
};
class Commisioned :public Employee{
    protected:
        int rate;
        float sale_amount;
    public:
        Commisioned(int r, float s){
            rate=r;
            sale_amount=s;
        }
        float calculateSalary(){
            return (sale_amount*rate/100+basic_salary);
        }
};
class Hourly:public Employee{
    protected:
        int extra_hours;
        float pay_per_hour;
    public:
        Hourly(int h,float p){
            extra_hours=h;
            pay_per_hour=p;
        }
        float calculateSalary(){
            return (basic_salary + pay_per_hour*extra_hours);
        }
};
class Regular:public Employee{
    protected:
        float bonus;
    public:
        Regular(int b){
           bonus=b; 
        }
    float calculateSalary(){
        return (basic_salary+bonus);
    }
};


int main()
{
    Employee e;
    Commisioned c(15,346.78);
    Hourly h(8,67.45);
    Regular(345.23);


    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