Creating PAYSLIP

closed account (9G3v5Di1)

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).


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include "_pause.h"

using namespace std;

class PaySlip{
  private:
    string name;
    int payGrade, basicSal, overtimeH, overtimeP, grossP, netP, withT;
  public:
    void setValue(string names, int payGrades, int basicSals, int overtimeHs, int overtimePs, int grossPs, int netPs, int withTs){
      name = names;
      payGrade = payGrades;
      basicSal = basicSals;
      overtimeH = overtimeHs;
      overtimeP = overtimePs;
      grossP = grossPs;
      netP = netPs;
      withT = withTs;
    }
    int getValue(){          // I am lacking of variable 'name' because the data type is string
      return payGrade, basicSal, overtimeH, overtimeP, grossP, netP, withT;
    }
    int determinePayGradeAndTaxRate(){
      
    }
    int computePay(){

    }
};

class Employee{

};


Help me step by step please, I want to clarify some steps.
1)How do I return values of those integers and a string?
2)What will I do with determinePayGradeAndTaxRate and computePay?
3)Should I inherit the properties from class PaySlip to class Employee?
4)How do I create an object of PaySlip inside the main method(included in class Employee)
5)Where will I put the int main? Is that the main method or not?
Last edited on
1) Question 1 is just a duplicate of:

http://www.cplusplus.com/forum/beginner/243063/

and you've already received answers there.

Please don't ask the same question in multiple threads. It wastes everyone's time, including yours, and decreases the quality of answers you may get.

2) I see nothing in what you've posted that explains how to determine someone's pay grade. To determine the tax rate, look at the salary, and use that to determine the tax rate.

What is computePay supposed to compute? The gross pay? The net pay? Your post doesn't make it clear.

3) Do you understand that inheritance models an "is-a" relationship? Is it true to say that an Employee is a PaySlip?

4) Your question isn't clear. You create an object of Payslip the same way as you'd create any other object or variable:

1
2
3
int a; // This creates an int
float b; // This creates a float
PaySlip c;  // This creates a PaySlip 


What do you mean by "inside the main method(included in class Employee)"? The main method isn't included inside any class. It's a standalone function, and is the entry point for your program.

5) Yes, int main is part of the definition of the main function. Specifically, it defines that the function will be called "main" and returns an int.
Last edited on
Topic archived. No new replies allowed.