Question

Write a c++ program to create a payroll based on these assumptions and requirements: A company...

Write a c++ program to create a payroll based on these assumptions and requirements:

A company called Data Housing Corp. employs a number of employees (say 5) all employees are paid on hourly base, any employee who works more than 40 hours is entitled to be paid overtime (1.5 for every hour exceeding 40).

Calculate :
1. The Gross income=(Rate*hours worked )+ overtime
2. The overtime= No. of hours exceeding 40 * Rate *1.5
3. State tax= gross*6%
4.Federal tax=gross*12%
5. Union fees= gross*2%
6. Net= Gross-(State Tax+Federal tax +Union fees)
7. Total Gross for all employees.
8. Average gross

Directions:

MUST USE:

a) Arrays

b) MUST use functions

-Your input consists of Employee First Name, Middle Initial, Last name, hours worked, rate per hour

-State tax, fed tax and union fees are constansts

-Your FORMATTED output includes all input information and all calculated information such as (gross, net, etc)

-Apply (whatever is applicable): Loops, constants, data validation, if, else, switch, arrays, precision

-input validation (hours greater than 0 and less than 60, rate greater than 0 and less than 50)

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

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
=================================

#include <fstream>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <vector>
using namespace std;

void displayOutput(string fnames[],string middle[], string lnames[], int workedhours[], double payrate[]);
double calcUnionTax(double grossPay, double uNIONTAX);
double calcFederalTax(double grossPay, double fEDERALTAX);
double calcStateTax(double grossPay, double sTATETAX);
double calGrossPay(int hours, double payRate);


int main() {
   //Declaring variables
   const int size = 5;
   string fnames[size];
string middle[size];
  
string lnames[size];

int workedhours[size];
double payrate[size];
  
for (int i = 0; i < size; i++) {
cout<<"Employee#" << (i + 1) << ":"<<endl;
cout<<"Enter First Name :";
cin>>fnames[i];
cout<<"Enter Middle Name :";
cin>>middle[i];
cout<<"Enter Last Name :";
cin>>lnames[i];
while(true)
{
cout<<"Enter No of worked hours :";
cin>>workedhours[i];
           if(workedhours[i]<0 || workedhours[i]>60)
           {
               cout<<"Invalid.Must be between 1-60"<<endl;
                       }   
                       else
                       break;
           }
          
while(true)
{
cout<<"Enter Payrate :$";
cin>>payrate[i];
           if(payrate[i]<0 || payrate[i]>40)
           {
               cout<<"** Invalid.Must be between 1-40 **"<<endl;
               }  
               else
               break;
           }
  
}
displayOutput(fnames,middle, lnames, workedhours, payrate);


  
  
   return 0;
}

void displayOutput(string fnames[],string middle[], string lnames[], int workedhours[], double payrate[]) {
//setting the precision to two decimal places
   std::cout << std::setprecision(2) << std::fixed;


double grossPay = 0.0,stateTax,fedtax,unionTax,net;
const double STATETAX=0.06;
const double FEDERALTAX=0.12;
const double UNIONTAX=0.01;
double totGross=0;
cout<<"\n\n\t\t\tdata Housing Corp. Weekly Payroll"<<endl;
cout<<"\t\t\t---------------------------------"<<endl;

  
for(int i=0;i<5;i++)
{
grossPay=calGrossPay(workedhours[i],payrate[i]);
stateTax=calcStateTax(grossPay,STATETAX);
fedtax=calcFederalTax(grossPay,FEDERALTAX);
unionTax=calcUnionTax(grossPay,UNIONTAX);
  
net=grossPay-stateTax-fedtax-unionTax;
cout<<"\nFirst name:"<<fnames[i]<<endl;
cout<<"Middle Initial :"<<middle[i]<<endl;
cout<<"Last name:"<<lnames[i]<<endl;
cout<<"Rate per hour:$"<<(payrate[i])<<endl;
cout<<"Hours Worked:"<<workedhours[i]<<endl;
cout<<"Gross:$"<<(grossPay)<<endl;
cout<<"State tax:$"<<(stateTax)<<endl;
cout<<"Federal Tax:$"<<(fedtax)<<endl;
cout<<"Union Fee:$"<<(unionTax)<<endl;
cout<<"Net:$"<<(net)<<endl;
totGross+=grossPay;
  
}
  
cout<<"\n\nTotal Gross Pay of all Employees :$"<<(totGross)<<endl;
cout<<"Average Gross Pay of all Employees :$"<<(totGross/5)<<endl;
}
double calcUnionTax(double grossPay, double uNIONTAX) {
  
return grossPay*uNIONTAX;
}
double calcFederalTax(double grossPay, double fEDERALTAX) {
  
return grossPay*fEDERALTAX;
}
double calcStateTax(double grossPay, double sTATETAX) {
  
return grossPay*sTATETAX;
}
double calGrossPay(int hours, double payRate) {
double gross=0.0;
if(hours<=40)
{
gross=hours*payRate;
}
else if(hours>40)
{
gross=40*payRate+(hours-40)*1.5*payRate;
}

return gross;
}

===================================

Output:

=====================Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
Write a c++ program to create a payroll based on these assumptions and requirements: A company...
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
  • Create a Java Program that calculates payroll for N number of workers in a company Using...

    Create a Java Program that calculates payroll for N number of workers in a company Using Arrays and Methods Pass Elements and Pass arrays             Array length = size of the array. Input :- First Name, MI, Last Name, Id, Hours Worked, Rate(1st method ) Constants :- State Tax, Federal Tax, Union Fees(2nd Method) Calculate The following using different methods Gross income(3rd Method) State Tax(4th Method) Federal Tax(5th Method) Union Fees(6th Method) Net Income(7th Method) Out Put (Formatted)(8th Method) (FirstName[i]...

  • Calculate Payroll computer programmer, and an administrator. The following payroll information is available for each K....

    Calculate Payroll computer programmer, and an administrator. The following payroll information is available for each K. Mello Company has three employees-a consultant, employee Administrator Consultant Computer Programmer $3,110 per week Regular earnings rate $36 per hour $44 per hour Overtime earnings rate 1.5 times hourly rate Not applicable 2 times hourly rate Federal income tax withheld $930 $244 $510 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay period,...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $36 per hour $3,010 per week Not applicable $48 per hour 1.5 times hourly rate Overtime earnings rate 2 times hourly rate Federal income tax withheld $930 $246 $505 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $3,010 per week $36 per hour $50 per hour Overtime earnings rate Not applicable 2 times hourly rate 1.5 times hourly rate Federal income tax withheld $910 $258 $515 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,710 per week $50 per hour $30 per hour 2 times hourly rate Not applicable 1.5 times hourly rate Overtime earnings rate Federal income tax withheld $925 $239 $500 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,010 per week $30 per hour $42 per hour Overtime earnings rate Not applicable 2 times hourly rate 1.5 times hourly rate Federal income tax withheld $910 $251 $495 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll...

    K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,610 per week $32 per hour $46 per hour Overtime earnings rate Not applicable 2 times hourly rate 1.5 times hourly rate Federal income tax withheld $915 $255 $505 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay period, the...

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

  • Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The fo...

    Calculate Payroll K. Mello Company has three employees-a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $2,710 per week $34 per hour $50 per hour Overtime earnings rate Not applicable 2 times hourly rate 1.5 times hourly rate Federal income tax withheld $910 $252 $500 For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

  • Calculate Payroll Breakin Away Company has three employees—a consultant, a computer programmer, and an administrator. The...

    Calculate Payroll Breakin Away Company has three employees—a consultant, a computer programmer, and an administrator. The following payroll information is available for each employee: Consultant Computer Programmer Administrator Regular earnings rate $4,000 per week $60 per hour $50 per hour Overtime earnings rate* Not applicable 1.5 times hourly rate 2 times hourly rate Number of withholding allowances 2 1 2 *For hourly employees, overtime is paid for hours worked in excess of 40 hours per week. For the current pay...

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