Question

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

Basic Salary Details:

Pay Grade Tax Rate

A 10,000-15,000 10%

B 20,000 -25,000 15%

C 30,000-35,000 20%

D 40,000-45,000 25%

E 50,000 -55,000 30%

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

The following are fixed values:

SSS = 500.00

Pag-ibig = 200.00

Philhealth = 100.00

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

Payslip.h

#ifndef _Payslip_h

#define _Payslip_h

#include<iostream>

#include<string>

using namespace std;

class Payslip

{

public:

Payslip();

Payslip(string,double,int);

void setName(string);

void setBasicSalary(double);

void setOvertimeHours(int);

string getName();

double getBasicSalary();

int getOvertimeHours();

double getOverTimePay();

double getGroosPay();

double getNetPay();

double getWithHoldingTax();

char getPayGrade();

double determinePayGradeAndTaxRate ();

void computePay();

private:

string name;

char payGrade;

double basicSalary,overtimePay,grossPay,netPay,withHoldingTax;

int overtimeHours;

};

#endif

Payslip.cpp

#include"Payslip.h"

Payslip::Payslip()

{

}

Payslip::Payslip(string name,double basic,int hours)

{

this->basicSalary=basic;

this->name=name;

this->overtimeHours=hours;

computePay();

}

void Payslip::setName(string name)

{

this->name=name;

}

void Payslip::setBasicSalary(double basic)

{

this->basicSalary=basic;

}

void Payslip::setOvertimeHours(int hours)

{

this->overtimeHours=hours;

}

string Payslip:: getName()

{

return name;

}

double Payslip:: getBasicSalary()

{

return basicSalary;

}

int Payslip:: getOvertimeHours()

{

return overtimeHours;

}

double Payslip:: getOverTimePay()

{

return overtimePay;

}

double Payslip:: getGroosPay()

{

return grossPay;

}

double Payslip:: getNetPay()

{

return netPay;

}

double Payslip::getWithHoldingTax()

{

return withHoldingTax;

}

char Payslip::getPayGrade()

{

return payGrade;

}

void Payslip:: computePay()

{

double SSS =500.00,Pagibig = 200.00,Philhealth = 100.00;

double tax=determinePayGradeAndTaxRate();

overtimePay=getOvertimeHours()*(0.01*getBasicSalary());

grossPay=getBasicSalary()+overtimePay;

withHoldingTax=getGroosPay()*(tax/100);

netPay=getGroosPay()-getWithHoldingTax()-SSS-Pagibig-Philhealth;

}

double Payslip::determinePayGradeAndTaxRate()

{

if(basicSalary>=10000 && basicSalary<=15000)

{

this->payGrade='A';

return 10;

}

else if(basicSalary>=20000 && basicSalary<=25000)

{

this->payGrade='B';

return 15;

}

else if(basicSalary>=30000 && basicSalary<=35000)

{

this->payGrade='C';

return 20;

}

else if(basicSalary>=40000 && basicSalary<=45000)

{

this->payGrade='C';

return 25;

}

else if(basicSalary>=50000 && basicSalary<=55000)

{

this->payGrade='E';

return 30;

}

else

{

this->payGrade='B';

return 30;

}

}

employee.cpp

#include"Payslip.h"

int main()

{

string name;

double basicSalary;

int hour;

cout<<"Enter your name: ";

cin>>name;

while(true)

{

cout<<"Enter the basic salary (>=10000): ";

cin>>basicSalary;

if(basicSalary>=10000)

break;

}

while(true)

{

cout<<"Enter the overtime hours (>=1): ";

cin>>hour;

if(hour>=1)

break;

}

Payslip p(name,basicSalary,hour);

cout<<" Employee Name :"<<p.getName()<<endl;

cout<<"Basic Salary :"<<p.getBasicSalary()<<endl;

cout<<"Pay Grade :"<<p.getPayGrade();

cout<<"No. of OT Hours :"<<p.getOvertimeHours()<<endl;

cout<<"OT Pay :"<<p.getOverTimePay()<<endl;

cout<<"Gross Pay :"<<p.getGroosPay()<<endl;

cout<<"Withholding Tax :"<<p.getWithHoldingTax()<<endl;

cout<<"Net Pay :"<<p.getNetPay()<<endl<<endl;

}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.

Add a comment
Know the answer?
Add Answer to:
C++ HELP! Create a class and name it Payslip. This class should have the following attributes...
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
  • 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 an abstract class Employee. Your Employee class should include the following attributes: First name (string)...

    Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings.      Create another class HourlyEmployee that inherits from the abstract Employee class.   HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...

  • Create an abstract class Employee. Your Employee class should include the following attributes: First name (string)...

    Create an abstract class Employee. Your Employee class should include the following attributes: First name (string) Last name (string) Employee id (string) Employee home street address (string) Employee home city (string) Employee home state (string) Write a constructor to initialize the above Employee attributes. Create an abstract method called earnings.      Create another class HourlyEmployee that inherits from the abstract Employee class.   HourEmployee must use the inherited parent class variables and add in attributes HourlyRate and HoursWorked. Your HourEmployee class should...

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

  • python code? 1. Create a class called Person that has 4 attributes, the name, the age,...

    python code? 1. Create a class called Person that has 4 attributes, the name, the age, the weight and the height [5 points] 2. Write 3 methods for this class with the following specifications. a. A constructor for the class which initializes the attributes [2.5 points] b. Displays information about the Person (attributes) [2.5 points] c. Takes a parameter Xage and returns true if the age of the person is older than Xage, false otherwise [5 points] 3. Create another...

  • In Java Create a class Worker. Your Worker class should include the following attributes as String...

    In Java Create a class Worker. Your Worker class should include the following attributes as String variables: Name, Worker ID, Worker Address, Worker City, Worker State Create the constructor that initializes the above worker attributes. Then make another class name HourlyWorker that inherits from the Worker class.   HourlyWOrker has to use the inherited parent class variables and add in hourlySalary and billableHours. Your HourlyWorker class should contain a constructor that calls the constructor from the Worker class to initialize the...

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

  • Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main()...

    Create a Java file named Ch6Asg.java that contains a public class named Ch6Asg containing a main() method. Within the same file, create another class named Employee, and do not declare it public. Create a field for each of the following pieces of information: employee name, employee number, hourly pay rate, and overtime rate. Create accessor and mutator methods for each field. The mutator method for the hourly pay rate should require the value to be greater than zero. If it...

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