Knowee
Questions
Features
Study Tools

Amazon has recently updated the salary structure for its employees in various designations. The employees are classified into three main groups: Project Managers, System Engineers, and Technical Assistants. Each designation has different allowances added to their basic pay(if basic pay=0, then salary=0). Project Managers receive all allowances(Additional Grade Pay, Dearness Allowance) except Travel Allowances (TA). System Engineers receive only basic pay, House Rental Allowance and TA, while Technical Assistants receive only fixed basic pay without any allowances. Implement this salary scheme in a C++ program where the base class Employee represents all employees' common attributes and behaviours. ProjectManager, SystemEngineer, and TechnicalAssistant should be derived classes from Employee. The Employee class should have a constructor to initialize common attributes like name and basic pay, and each derived class should have its own constructor to initialize its specific attributes. Write a main() function to display the salary with respective class objects. Sample input John Smith 5000 1000 500 Emily Johnson 4000 300 800 Michael Brown 3000 Sample output 6500 5100

Question

Amazon has recently updated the salary structure for its employees in various designations. The employees are classified into three main groups: Project Managers, System Engineers, and Technical Assistants. Each designation has different allowances added to their basic pay(if basic pay=0, then salary=0). Project Managers receive all allowances(Additional Grade Pay, Dearness Allowance) except Travel Allowances (TA). System Engineers receive only basic pay, House Rental Allowance and TA, while Technical Assistants receive only fixed basic pay without any allowances. Implement this salary scheme in a C++ program where the base class Employee represents all employees' common attributes and behaviours. ProjectManager, SystemEngineer, and TechnicalAssistant should be derived classes from Employee. The Employee class should have a constructor to initialize common attributes like name and basic pay, and each derived class should have its own constructor to initialize its specific attributes. Write a main() function to display the salary with respective class objects.

Sample input John Smith 5000 1000 500 Emily Johnson 4000 300 800 Michael Brown 3000

Sample output 6500 5100

...expand
🧐 Not the exact question you are looking for?Go ask a question

Solution

Here is a simple implementation of the salary scheme in C++:

#include<iostream>
#include<string>
using namespace std;

class Employee {
protected:
    string name;
    double basic_pay;
public:
    Employee(string n, double bp) : name(n), basic_pay(bp) {}
    virtual double calculateSalary() = 0; // Pure virtual function
};

class ProjectManager : public Employee {
private:
    double additional_grade_pay;
    double dearness_allowance;
public:
    ProjectManager(string n, double bp, double agp, double da) : Employee(n, bp), additional_grade_pay(agp), dearness_allowance(da) {}
    double calculateSalary() {
        return basic_pay + additional_grade_pay + dearness_allowance;
    }
};

class SystemEngineer : public Employee {
private:
    double house_rent_allowance;
    double travel_allowance;
public:
    SystemEngineer(string n, double bp, double hra, double ta) : Employee(n, bp), house_rent_allowance(hra), travel_allowance(ta) {}
    double calculateSalary() {
        return basic_pay + house_rent_allowance + travel_allowance;
    }
};

class TechnicalAssistant : public Employee {
public:
    TechnicalAssistant(string n, double bp) : Employee(n, bp) {}
    double calculateSalary() {
        return basic_pay;
    }
};

int main() {
    ProjectManager pm("John Smith", 5000, 1000, 500);
    SystemEngineer se("Emily Johnson", 4000, 300, 800);
    TechnicalAssistant ta("Michael Brown", 3000);

    cout << pm.calculateSalary() << endl;
    cout << se.calculateSalary() << endl;
    cout << ta.calculateSalary() << endl;

    return 0;
}

This program defines an abstract base class Employee with a pure virtual function calculateSalary(). The derived classes ProjectManager, SystemEngineer, and TechnicalAssistant each implement this function according to their respective salary calculation rules. The main() function creates an object of each class, calculates the salary, and prints it.

This problem has been solved

Similar Questions

ABC company Ltd. is interested to computerize the pay calcuation of their employee in the form of Basic pay, Dearness Allowance (DA) and House Rent Allowance (HRA). DA and HRA are calculated as certain % of Basic pay (For example, DA is 80% of Basic pay, and HRA is 30% of Basic pay). They have the deduction in the salary as PF which is 12% of Basic pay. Propose a computerized solution for the above said problem.

For the Employee Class Program in this tutorial, what if we need the capability to update the salary for employees? What information is needed to perform this task, and what code segment implements obtaining it in a method?a.)Employees file information and the new salarydef upd_salary(): employees = read_employees() new_sal = input("Enter the new salary of the employee: ")b.)The new salarydef upd_salary(employees): new_sal = input("Enter the new salary of the employee: ")c.)Employee iddef upd_salary(employees): empid = input("Enter the employee ID: ")d.)Employee id and the new salarydef upd_salary(employees): empid = input("Enter the employee ID: ") new_sal = input("Enter the new salary of the employee: ")

Implement a C++ program to manage the salary structure for employees at a university, including Head of Department (HOD), Faculty, and Technical Assistants. Begin by defining a base class Employee with common attributes name and basicPay. Create derived classes, such as HOD, Faculty, and TechnicalAssistant, that are inherited from the employee. Each derived class should have its own method, calculateSalary(), to compute the total salary based on its specific attributes and the basic pay. The salary should also include a bonus based on the overall salary:If the overall salary is less than 50,000, the bonus is 5% of the overall salary.If the overall salary is between 50,000 and 100,000, the bonus is 7% of the overall salary.If the overall salary is more than 100,000, the bonus is 10% of the overall salary.HODs receive additional grade pay, dearnessAllowance, house RentalAllowance, and travelAllowance; faculty receive house RentalAllowance and travelAllowance; and Technical Assistants receive the basic pay and travelAllowance. In the main() function, instantiate objects of each employee type with sample data, calculate their total salary and bonus using the calculateSalary() method, and display them.

One method of compensation in a global business is to pay a similar base salary company wide or region wide and offer expatriates an allowance based on specific market conditions in each country. This is known as _____.Group of answer choicesbroadbandingthe balance sheet approachskills-based paycompetence-based paya pay grading system

rect answerA class Manager wants to implement an interface Salary. Which of the following is the correct way of implementing it?

1/1

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.