Question

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

------------->  The following are fixed values: SSS = 500.00 Pag-ibig = 200.00 Philhealth = 100.00

--------------> Pay Grades:

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%
0 0
Add a comment Improve this question Transcribed image text
Answer #1

IF YOU HAVE ANY DOUBTS COMMENT BELOW I WILL BE THERE TO HELP YOU

ANSWER:

CODE:

#include "stdafx.h"
//Header files
#include<iostream>
#include<string>
#include<iomanip>
#include<locale>
#include<sstream>
using namespace std;
//Format method for monetary values
string FormatMonetaryValues(double value)
{
   stringstream ss;
   ss.imbue(locale(""));
   ss <<fixed <<setprecision(2)<< value;
   return ss.str();
}
//Create a class Payslip
class Payslip {
   //Member variables
private:
   string name;
   char paygrade;
   double basicsalary;
   double overtimehours;
   double overtimepay;
   double grosspay;
   double net ;
   double withholdingtax;
   //Member functions
public:
   //Default constructor
   Payslip() {

   }
   //Parameterized constructor
   //Here check the conditions before setting values
   //Then call calculation method to set reamaining values
   Payslip(string name, double basicSalary, double overtime) {
       this->name = name;
       while (basicSalary < 10000) {
           cout << "Error !!! Please enter basic salary greater tha or equal 10000" << endl;
           cout << "Enter basic pay:";
           cin >> basicSalary;
       }
       basicsalary = basicSalary;
       while (overtime < 1) {
           cout << "Error!!!! Please enter overtime greater than equal to 1" << endl;
           cout << "Enter overtime hours:";
           cin >> overtime;
       }
       overtimehours = overtime;
       PayGradeTaxCalculation();
       computePay();
   }
   //Accessor
   //Which return all data variable values for further use
   string getName() {
       return name;
   }
   char getPayGrade() {
       return paygrade;
   }
   double getBasicSalary() {
       return basicsalary;
   }
   double getOverTime() {
       return overtimehours;
   }
   double getOvertimePay() {
       return overtimepay;
   }
   double getGrossPay() {
       return grosspay;
   }
   double getNet() {
       return net;
   }
   double getWithHeldTax() {
       return withholdingtax;
   }
   //Mutator
   //Set value according to the condition basicpay>10000 and oT time>=1
   //Call methods to set other values
   void setPaySlip(string name, double basicSalary, double overtime) {
       this->name = name;
       while (basicSalary < 10000) {
           cout << "Error !!! Please enter basic salary greater tha or equal 10000" << endl;
           cout << "Enter basic pay:";
           cin >> basicSalary;
       }
       basicsalary = basicSalary;
       while (overtime < 1) {
           cout << "Error!!!! Please enter overtime greater than equal to 1" << endl;
           cout << "Enter overtime hours:";
           cin >> overtime;
       }
       overtimehours = overtime;
       PayGradeTaxCalculation();
       computePay();
   }
   //To find the tax rate and pay grade
   void PayGradeTaxCalculation() {
       if (basicsalary == 10000){
           this->paygrade = 'A';
           this->withholdingtax = 10;
       }
       else if (basicsalary==20000) {
           this->paygrade = 'A';
           this->withholdingtax = 15;
       }
       else if (basicsalary == 30000) {
           this->paygrade = 'A';
           this->withholdingtax = 20;
       }
       else if (basicsalary == 40000) {
           this->paygrade = 'A';
           this->withholdingtax = 25;
       }
       else if (basicsalary == 40000) {
           this->paygrade = 'A';
           this->withholdingtax = 30;
       }
       else if (basicsalary == 15000) {
           this->paygrade = 'B';
           this->withholdingtax = 10;
       }
       else if (basicsalary == 25000) {
           this->paygrade = 'B';
           this->withholdingtax = 15;
       }
       else if (basicsalary == 35000) {
           this->paygrade = 'B';
           this->withholdingtax = 20;
       }
       else if (basicsalary == 45000) {
           this->paygrade = 'B';
           this->withholdingtax = 25;
       }
       else if (basicsalary >= 55000) {
           this->paygrade = 'B';
           this->withholdingtax = 30;
       }
   }
   //All other pays are calculated here
   void computePay() {
       overtimepay = 40 * (basicsalary*.01);
       grosspay = basicsalary + overtimepay;
       withholdingtax = grosspay * (withholdingtax / 100);
       double fixedvalues = 800.00;
       net = grosspay - withholdingtax - fixedvalues;  
   }
};
//Test method
   int main()
   {
       //An object created
       Payslip ps("Mahesh Babu", 25000, 1.5);
       //Display Employee details
       cout << "Employee Name : " << ps.getName() << " Basic Salary : Php " << FormatMonetaryValues(ps.getBasicSalary()) << " Pay Grade : " << ps.getPayGrade() << " No.of OT Hours : " << ps.getOverTime() << " OT Pay : Php " << FormatMonetaryValues(ps.getOvertimePay()) << " Gross Pay : Php " << FormatMonetaryValues(ps.getGrossPay()) << " Withholding Tax : Php " << FormatMonetaryValues(ps.getWithHeldTax()) << " Net Pay : Php " << FormatMonetaryValues(ps.getNet()) << endl;
       cout << "-----------------------------------------------------------------" << endl;
       //Set pay slip change
       Payslip ps1;
       ps1.setPaySlip("Argav Lol", 35000, 1.5);
       cout << "Employee Name : " << ps1.getName() << " Basic Salary : Php " << FormatMonetaryValues(ps1.getBasicSalary()) << " Pay Grade : " << ps1.getPayGrade() << " No.of OT Hours : " << ps1.getOverTime() << " OT Pay : Php " << FormatMonetaryValues(ps1.getOvertimePay()) << " Gross Pay : Php " << FormatMonetaryValues(ps1.getGrossPay()) << " Withholding Tax : Php " << FormatMonetaryValues(ps1.getWithHeldTax()) << " Net Pay : Php " << FormatMonetaryValues(ps1.getNet()) << endl;
       return 0;
   }

--------------------------

Output

Employee Name : Mahesh Babu
Basic Salary : Php 25,000.00
Pay Grade : B
No.of OT Hours : 1.5
OT Pay : Php 10,000.00
Gross Pay : Php 35,000.00
Withholding Tax : Php 5,250.00
Net Pay : Php 28,950.00
-----------------------------------------------------------------
Employee Name : Argav Lol
Basic Salary : Php 35,000.00
Pay Grade : B
No.of OT Hours : 1.5
OT Pay : Php 14,000.00
Gross Pay : Php 49,000.00
Withholding Tax : Php 9,800.00
Net Pay : Php 38,400.00
Press any key to continue . . .

RATE THUMBSUP PLEASE

Add a comment
Know the answer?
Add Answer to:
Hi There Guru's, I need assistance with my C++. Thank you in Advance. The problem states...
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...

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

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

  • J Inc. has a file with employee details. You are asked to write a C++ program...

    J Inc. has a file with employee details. You are asked to write a C++ program to read the file and display the results with appropriate formatting. Read from the file a person's name, SSN, and hourly wage, the number of hours worked in a week, and his or her status and store it in appropriate vector of obiects. For the output, you must display the person's name, SSN, wage, hours worked, straight time pay, overtime pay, employee status and...

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

  • Write a C program that will calculate the gross pay of a set of employees. The...

    Write a C program that will calculate the gross pay of a set of employees. The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. The program determines the overtime hours (anything over 40 hours), the gross pay and then outputs a table in the following format. Column alignment, leading zeros in Clock#, and zero suppression in float fields is important. Use 1.5 as the overtime pay...

  • 1.Calculate the Regular Pay and Overtime Pay based on a regular 40-hour workweek in cells F5...

    1.Calculate the Regular Pay and Overtime Pay based on a regular 40-hour workweek in cells F5 and G5 respectively. Pay overtime only for overtime hours. Note that the base work hours and overtime rate is given under the Assumptions section of the Payroll Data worksheet. In cell H5, calculate the Gross Pay based on the regular and overtime pay. 2. Write a formula in cell I5 to calculate the Taxable Pay. Multiply the number of dependents (given in column C)...

  • Please answer part I, iii and iv Syarikat Smart Store Hypermarket Sdn. Bhd. wants to create...

    Please answer part I, iii and iv Syarikat Smart Store Hypermarket Sdn. Bhd. wants to create a system that will calculate the weekly pay for its employees, based on the category and rate given in the table below. The employees in the category A1, A2 and M1 are paid standard rate for the first 44 hours, followed by 1.5 the standard rate for overtime pay. There is no overtime pay for M2 and BB categories. The total work hours for...

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

  • C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their...

    C++ Program The Ward Bus Manufacturing Company has recently hired you to help them convert their manual payroll system to a computer-based system. Write a program to produce a 1-week payroll report for only one employee to serve as a prototype (model) for the administration to review. Input for the system will be the employee’s 4-digit ID number, the employee’s name, hours worked that week, and the employee’s hourly pay rate. Output should consist of the employee’s ID number, the...

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