Question

Questions:(to be answered within the video) Write a C++ program with the following specifications: 1. Create...

Questions:(to be answered within the video)

Write a C++ program with the following specifications:

1. Create a class and name it Payslip. This class should have the following attributes or properties: name,pay grade, basic salary, overtime hours, overtime pay, gross pay, net pay and withholding tax.
2. Define the accessors and mutators of the Payslip class based on its attributes or properties.  This class should also have the following methods: determinePayGradeAndTaxRate and computePay.
3. Create another class and name it Employee.  This class will contain the main method.
4. In the main method, instantiate an object of the Payslip class. Input the employee name, basic salary, and number of overtime (OT) hours.  These values must be set to the object of the Payslip class.  Apply validations for input as follows:
a. Basic salary should not be less than 10,000.
b. Minimum overtime hours is 1 hour.

5. Basic Salary Details:

Pay Grade A

Pay Grade B

Tax Rate

10,000

15,000

10%

20,000

25,000

15%

30,000

35,000

20%

40,000

45,000

25%

50,000

55,000

30%

6. The computation is as follows:

Gross pay = basic salary + OT pay

OT pay = no. of OT hours * 1% of basic salary

Net pay = gross pay – withholding tax – fixed values

Withholding tax = gross pay * tax rate

Note: Basic salary greater than or equal to 55,000 will have a pay grade of B and a tax rate of 30%.

7. The following are fixed values:

SSS = 500.00

Pag-ibig = 200.00

Philhealth = 100.00

8. Output should contain the following:

Employee Name :

Basic Salary:

Pay Grade:

No. of OT Hours:

OT Pay:

Gross Pay:

Withholding Tax:

Net Pay:

Note: Input of data and display of results should be defined on the main method. All monetary display should be formatted with comma separators, 2 decimal places, and “Php (Ex: Php 32,546.95).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// do comment if any problem arises

// code

// the Employee class is given in context of java, it is not required in c++ for main method

#include <iostream>

using namespace std;

class Payslip

{

private:

    string name;

    char pay_grade;

    int overtime_hours;

    float basic_salary, overtime_pay, gross_pay, net_pay, witholding_tax;

public:

    void set_name(string name)

    {

        this->name = name;

    }

    string get_name()

    {

        return name;

    }

    char get_pay_grade()

    {

        get_tax_rate();

        return pay_grade;

    }

    void set_overtime_hours(int overtime_hours)

    {

        this->overtime_hours = overtime_hours;

    }

    int get_overtime_hours()

    {

        return overtime_hours;

    }

    void set_basic_salary(float basic_salary)

    {

        this->basic_salary = basic_salary;

    }

    float get_basic_salary()

    {

        return basic_salary;

    }

    float get_overtime_pay()

    {

        overtime_pay = overtime_hours * basic_salary * 0.01;

        return overtime_pay;

    }

    float get_gross_pay()

    {

        gross_pay = basic_salary + get_overtime_pay();

        return gross_pay;

    }

    float get_tax_rate()

    {

        if (basic_salary <= 15000)

        {

            pay_grade = 'B';

            if (basic_salary <= 10000)

                pay_grade = 'A';

            return 0.1;

        }

        else if (basic_salary <= 25000)

        {

            pay_grade = 'B';

            if (basic_salary <= 20000)

                pay_grade = 'A';

            return 0.15;

        }

        else if (basic_salary <= 35000)

        {

            pay_grade = 'B';

            if (basic_salary <= 30000)

                pay_grade = 'A';

            return 0.2;

        }

        else if (basic_salary <= 45000)

        {

            pay_grade = 'B';

            if (basic_salary <= 40000)

                pay_grade = 'A';

            return 0.25;

        }

        else

        {

            pay_grade = 'A';

            if (basic_salary >= 50000)

                pay_grade = 'B';

            return 0.3;

        }

    }

    float get_withholding_tax()

    {

        float tax_rate = get_tax_rate();

        witholding_tax = gross_pay * tax_rate;

        return witholding_tax;

    }

    float get_net_pay()

    {

        float fixed_values = 500 + 200 + 100;

        return gross_pay - get_withholding_tax() - fixed_values;

    }

};

int main()

{

    // create employee

    Payslip test;

    test.set_name("Rahul Shetty");

    test.set_basic_salary(33000);

    test.set_overtime_hours(10);

    // print employee details

    cout << "Employee Name: " << test.get_name() << endl;

    cout << "Basic Salary: " << test.get_basic_salary() << endl;

    cout << "Pay Grade: " << test.get_pay_grade() << endl;

    cout << "No. of OT Hours: " << test.get_overtime_hours() << endl;

    cout << "OT Pay: " << test.get_overtime_pay() << endl;

    cout << "Gross Pay: " << test.get_gross_pay() << endl;

    cout << "Withholding Tax: " << test.get_withholding_tax() << endl;

    cout << "Net Pay: " << test.get_net_pay() << endl;

}

Output:

Add a comment
Know the answer?
Add Answer to:
Questions:(to be answered within the video) Write a C++ program with the following specifications: 1. Create...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ HELP! Create a class and name it Payslip. This class should have the following attributes...

    C++ HELP! Create a class and name it Payslip. This class should have the following attributes or properties: name, pay grade, basic salary, overtime hours, overtime pay, gross pay, net pay and withholding tax. Define the accessors and mutators of the Payslip class based on its attributes or properties. This class should also have the following methods: determinePayGradeAndTaxRate and computePay. Create another class and name it Employee. This class will contain the main method. In the main method, instantiate an...

  • Hi There Guru's, I need assistance with my C++. Thank you in Advance. The problem states...

    Hi There Guru's, I need assistance with my C++. Thank you in Advance. The problem states that 2 SEPARATE CLASSES are to be made and All monetary display should be formatted with comma separators, 2 decimal places, ex: “Php” (Ex: Php 32,546.95). 1. Create a class and name it Payslip. This class should have the following attributes or properties: name, pay grade, basic salary, overtime hours, overtime pay, gross pay, net pay and withholding tax. 2. Define the accessors and...

  • Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code:...

    Introduction to computer class, Java programming through eclipse: Ue the following criteria to create the code: SALARY Input first and last name - Output the names last, first in your output - Make the federal withholding rate a constant 20% (not an input value) No state tax Generate two new values: regular pay and overtime pay - 40 hours workedor less - Regular pay is pay rate * hours worked - Overtime pay is 0 Otherwise - Regular pay is...

  • create java application with the following specifications: -create an employee class with the following attibutes: name...

    create java application with the following specifications: -create an employee class with the following attibutes: name and salary -add constuctor with arguments to initialize the attributes to valid values -write corresponding get and set methods for the attributes -add a method in Employee called verify() that returns true/false and validates that the salary falls in range1,000.00-99,999.99 Add a test application class to allow the user to enter employee information and display output: -using input(either scanner or jOption), allow user to...

  • ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for...

    ASAP Please. Python Program Description Create an object-oriented program that allows you to enter data for employees. Specifications Create an abstract Employee class that provides private attributes for the first name, last name, email address, and social security number. This class should provide functions that set and return the employee’s first name, last name, email address, and social security number. This class has a function: get_net_income which returns 0. Create a Manager class that inherits the Employee class. This class...

  • Create the Python code for a program adhering to the following specifications. Write an Employee class...

    Create the Python code for a program adhering to the following specifications. Write an Employee class that keeps data attributes for the following pieces of information: - Employee Name (a string) - Employee Number (a string) Make sure to create all the accessor, mutator, and __str__ methods for the object. Next, write a class named ProductionWorker that is a subclass of the Employee class. The ProductionWorker class should keep data attributes for the following information: - Shift number (an integer,...

  • Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The...

    Python 3 Question Please keep the code introductory friendly and include comments. Many thanks. Prompt: The owners of the Annan Supermarket would like to have a program that computes the weekly gross pay of their employees. The user will enter an employee’s first name, last name, the hourly rate of pay, and the number of hours worked for the week. In addition, Annan Supermarkets would like the program to compute the employee’s net pay and overtime pay. Overtime hours, any...

  • You are to write a program that will process employees and their pay. For each employee...

    You are to write a program that will process employees and their pay. For each employee the program will read in an employee’s name and hourly pay rate. It should also read in the number of hours worked each day for 5 days and calculate his or her total number of hours worked. You must read the hours using a loop. The program should output the employee’s name, gross pay, total withholding amount and net pay. Withholding is made up...

  • This is done in C++ Create an Employee class using a separate header file and implementation...

    This is done in C++ Create an Employee class using a separate header file and implementation file. Review your UML class diagram for the attributes and behaviors The calculatePay() method should return 0.0f. The toString() method should return the attribute values ("state of the object"). Create an Hourly class using a separate header file and implementation file. The Hourly class needs to inherit from the Employee class The calculatePay() method should return the pay based on the number of hours...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT