Knowee
Questions
Features
Study Tools

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.

Question

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.

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

Solution

Here is a simple implementation of the problem in C++:

#include<iostream>
using namespace std;

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

class HOD : public Employee {
    private:
        double gradePay, dearnessAllowance, houseRentalAllowance, travelAllowance;
    public:
        HOD(string n, double bp, double gp, double da, double hra, double ta) : Employee(n, bp), gradePay(gp), dearnessAllowance(da), houseRentalAllowance(hra), travelAllowance(ta) {}
        double calculateSalary() {
            double totalSalary = basicPay + gradePay + dearnessAllowance + houseRentalAllowance + travelAllowance;
            return totalSalary + calculateBonus(totalSalary);
        }
};

class Faculty : public Employee {
    private:
        double houseRentalAllowance, travelAllowance;
    public:
        Faculty(string n, double bp, double hra, double ta) : Employee(n, bp), houseRentalAllowance(hra), travelAllowance(ta) {}
        double calculateSalary() {
            double totalSalary = basicPay + houseRentalAllowance + travelAllowance;
            return totalSalary + calculateBonus(totalSalary);
        }
};

class TechnicalAssistant : public Employee {
    private:
        double travelAllowance;
    public:
        TechnicalAssistant(string n, double bp, double ta) : Employee(n, bp), travelAllowance(ta) {}
        double calculateSalary() {
            double totalSalary = basicPay + travelAllowance;
            return totalSalary + calculateBonus(totalSalary);
        }
};

double calculateBonus(double salary) {
    if (salary < 50000)
        return salary * 0.05;
    else if (salary >= 50000 && salary <= 100000)
        return salary * 0.07;
    else
        return salary * 0.10;
}

int main() {
    HOD hod("John", 50000, 10000, 5000, 2000, 1000);
    Faculty faculty("Jane", 40000, 2000, 1000);
    TechnicalAssistant ta("Joe", 30000, 1000);

    cout << "HOD Salary: " << hod.calculateSalary() << endl;
    cout << "Faculty Salary: " << faculty.calculateSalary() << endl;
    cout << "Technical Assistant Salary: " << ta.calculateSalary() << endl;

    return 0;
}

This program defines a base class Employee with common attributes name and basicPay. It also defines derived classes HOD, Faculty, and TechnicalAssistant that inherit from Employee. Each derived class has its own calculateSalary() method to compute the total salary based on its specific attributes and the basic pay. The calculateBonus() function is used to calculate the bonus based on the overall salary. In the main() function, objects of each employee type are instantiated with sample data, their total salary and bonus are calculated using the calculateSalary() method, and they are displayed.

This problem has been solved

Similar Questions

Design a structure in C to represent an employee's information, including their name, employee ID, department, and salary. Additionally, write a program that allows users to input employee data, display employee information, and update an employee's salary. write a code for demonstrating the implementation of the structure and program functionalities.input and output Enter employee details:Enter employee name: John DoeEnter employee ID: 101Enter department: SalesEnter salary: 50000Employee Information:Name: John Employee ID: 101 Department:Sales Salary: 50000.00Enter new salary: 55000Salary updated successfully.Updated Employee Information:Name: JohnEmployee ID: 101Department: SalesSalary: 55000.00

Create a class employee with protected members:Name,age,degree,genderCreate a member function to read the details.  Create a derived class department by inheriting the employee class privately.Declare the protected members: department_name, designation.Create a member function to read the details of the department.Create a member function to display the details of employee class and department class.Create a derived class salary by inheriting the employee class privately with protected members: basic payCreate default constructor to read basic pay.Define a member function to calculate the gross pay. Gross_pay=basic_pay+DA+HRADA=30% of basic payHRA =12% of basic payCreate a member function to display the details of employee class and the grosspay.

Create a class Employee with members name and ID and a default constructor to read the details of employeeCreate a derived class Salary from employee with members basic pay. Create a default constructor to read the basic pay.Create a derived class loan from salary with members DA,HRA,loan_amout, net_pay.Create a default constructor to read the loan_amount. Define a member function to calculate the netpay.Net_pay= (basic_pay+DA+HRA)-loan_amountDA=30% of basic payHRA =12% of basic pay

Create a Java  base class called Employee. Use this class to store two double-type values that could be used to compute the salary of employees. Also,the base class should have a static variable ‘totalemp’  to keep track of the total number of employees created. Derive two specific classes called part_time and full_time from the base employee. Add a member function called as get_basic() to get the basic pay and another member called display_salary() to compute and display the salary of the employees. Using these three classes, design a program that will accept the basic pay of part_time and full_time employees interactively. Remember the two values given as input will be treated as the basic pay of the employees and the following information is used for calculating the salaries of both the part-time as well as full-time employees. Print invalid if the basic_salary of part-time employee and basic_salary of full-time employee are not met the ”Boundary Condition”Part time                                         Full timeHRA = 20% of basic pay                    HRA = 30% of basic payDA = 72% of basic pay                      DA = 80% of basic paySalary = Basic + HRA + DA              Salary = Basic + HRA + DABoundary Condition:0 < basic_salary of part-time employee <= 10000000 < basic_salary of full-time employee <= 1000000Input Format:First line to enter the basic_salary of part-time employee and basic_salary of full-time employeeOutput Format:Total salary of part-time employee and total salary of full-time employee.Total number of employees processed Sample Testcase Input-1:50007000000Sample Testcase Output-1:8900.0invalid1 Sample Testcase Input-2:30000600000Sample Testcase Output-2:42720.0110400.02 Sample Testcase Input-3:0900000Sample Testcase Output-3:invalid216000.01

You are tasked with developing a software system for managing different types of employees in a company. The company has three types of employees: full-time employees, part-time employees, and consultants. Each type of employee has different attributes and calculation methods for calculating their monthly salary.Full-time employees receive a fixed monthly salary.Part-time employees are paid based on the number of hours they work and rate per hour.Consultants are paid based on the number of hours they work and an hourly rate.Design a C++ program that utilizes runtime polymorphism to model this scenario. Create a base class Employee with virtual functions calculateSalary() and displayDetails(). Derive three classes FullTimeEmployee, PartTimeEmployee, and Consultant from Employee, each implementing its own version of calculateSalary() and displayDetails() based on the rules described above.Then, demonstrate the use of runtime polymorphism by creating an array of Employee pointers containing instances of full-time employees, part-time employees, and consultants. Populate the array with objects of each type and iterate over it, calling the calculateSalary() and displayDetails() functions for each employee. Input Format:Enter name of full-time employeeEnter monthly salaryEnter name of part-time employeeEnter hourly rateEnter hours workedEnter name of consultantEnter hourly rateEnter hours worked

1/3

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.