I need some help with this if someone can help me that be great OBJECT : To comp
ID: 3717076 • Letter: I
Question
I need some help with this if someone can help me that be great
OBJECT: To compute the payroll in a company of 10 employees, given an employee’s id number, pay rate, number of hours, and tax rate.
INPUT: For each employee, his id number, pay rate and number of hours. You will prompt the user with a friendly message to enter an employee’s id number, pay rate and number of hours.
OUTPUT: The following table:
EMPLOYEE ID GROSS PAY NET PAY
101 540.58 480.40
158 796.32 630.20
. . . . . . . . . .
Also print at the end, the total gross pay, and the total net pay for the company.
METHOD:
You need the following functions:
Write the function void get_emp_rec(int &id, double &prate, double &hours) that reads an employee’s id number, pay rate and number of hours with an appropriate message. The ID, pay rate, and the number of hours are using the reference parameters id, prate, and hours, respectively.
Write the function double compute_gpay(double hours, double prate) that receives the number of hours and the pay rate of an employee using the value parameters hours and prate respectively, and then computes the gross pay ( hours * prate) and returns it.function
Write a function double compute_taxes(double gpay) that receives an employee’s gross pay using the value parameter gpay, computes the appropriate tax deduction and returns it. The tax deduction is computed as follows:
If the gross pay is less than or equal to 1000.00, the tax deduction is 4% of the gross pay;
If the gross pay is greater than 1000.00 but less than 1500.00, it is 5% of the gross pay;
otherwise, it is 6 % of the gross pay.
Write the function double compute_npay(double gpay) that receives an employee’s gross pay using the value parameter gpay, computes the net pay and returns it. The net pay is the gross pay minus the tax deduction. To compute the net pay, it first calls function compute_taxes() to compute the tax deduction.
Write a function void printtables(int ids[], double gpays[], double npays[], int size) that receives the arrays and their size and prints them with appropriate headings.
Function main:
You need 3 arrays of 10 elements: int empid[10] (to hold employees’ id numbers), double empgrosspay[10] (to hold employees’ gross pays) and double empnetpay[10] (to hold employees’ net pays). These arrays are declared in function main.
In a loop , function main reads students’ records by calling get_emp_rec(), computes their gross pay by calling compute_gpay(), and computes their net pay by calling compute_npay(). It also constructs the three arrays of id numbers, gross pays, and net pays, and computes the total gross pay and the total net pay.
Next, it prints the tables by calling printtables() and then prints the company total gross pay and total net pay.
TOPICS: arithmetic operations, cin, cout, program documentation, while/for loop, if-else statement, arrays, functions, formatted output.
You must return the following (in this order):
The program source file
The program output.
Explanation / Answer
PROGRAM
#include<iostream>
#include<iomanip>
using namespace std;
// Create and implement get_emp_rec() function with reference parameters
void get_emp_rec(int &id,double &prate,double &hours)
{
// readding elements
cout<<" Enter Employee ID: "; cin>>id;
cout<<" Enter Pay Rate: "; cin>>prate;
cout<<" Enter Hours: "; cin>>hours;
}
// Create and implement compute_gpay() function with two parameters hours and prate
double compute_gpay(double hours, double prate)
{
return hours*prate; // calculate hours*prate value and return
}
// Create and implement compute_taxes() function with single parameter gpay
double compute_taxes(double gpay)
{
if(gpay<=1000) // check condition if gross pay < 1000 then give tax 4%
return (gpay*4)/100; // return 4% tax value
else
if(gpay>1000&&gpay<=1500) // check condition if gross pay in between 1000 and 1500 then give tax 5%
return (gpay*5)/100; // return 5% tax value
else
return (gpay*6)/100; // else return 6% tax value
}
// Create and implement compute_npay() function with single parameter gpay
double compute_npay(double gpay)
{
double tax=compute_taxes(gpay); // calling compute_taxes() function receive tax
return gpay-tax; // return net pay gross pay - tax value
}
// Create and implement printtables() function with 4 parameters
void printtables(int ids[], double gpays[], double npays[], int size)
{
// display format using setw() function provide spaces
cout<<"EMPLOYEE ID"<<setw(20)<<"GROSS PAY"<<setw(20)<<"NET PAY"<<endl;
for(int i=0;i<size;i++) // create for loop until size
cout<<ids[i]<<setw(25)<<gpays[i]<<setw(25)<<npays[i]<<endl; // display actual data
}
int main()
{
// declare array variables
int empid[10];
double empgrosspay[10];
double empnetpay[10];
for(int i=0;i<10;i++) // create for loop of 10 elements
{
get_emp_rec(empid[i],empgrosspay[i],empnetpay[i]); // calling get_emp_rec() function
empgrosspay[i]=compute_gpay(empgrosspay[i],empnetpay[i]); // calling compute_gpay() function and receive return value into empgrosspay array
empnetpay[i]=compute_npay(empgrosspay[i]); // calling compute_npay() function and receive return value empnetpay array
}
printtables(empid,empgrosspay,empnetpay,10); // calling printables() function for print elements
}
OUTPUT
Enter Employee ID: 101
Enter Pay Rate: 52
Enter Hours: 12
Enter Employee ID: 102
Enter Pay Rate: 68
Enter Hours: 7
Enter Employee ID: 125
Enter Pay Rate: 78
Enter Hours: 13
Enter Employee ID: 146
Enter Pay Rate: 89
Enter Hours: 14
Enter Employee ID: 138
Enter Pay Rate: 69
Enter Hours: 3
Enter Employee ID: 144
Enter Pay Rate: 89
Enter Hours: 7
Enter Employee ID: 188
Enter Pay Rate: 99
Enter Hours: 12
Enter Employee ID: 165
Enter Pay Rate: 84
Enter Hours: 9
Enter Employee ID: 122
Enter Pay Rate: 78
Enter Hours: 13
Enter Employee ID: 166
Enter Pay Rate: 86
Enter Hours: 5
EMPLOYEE ID GROSS PAY NET PAY
101 624 599.04
102 476 456.96
125 1014 963.3
146 1246 1183.7
138 207 198.72
144 623 598.08
188 1188 1128.6
165 756 725.76
122 1014 963.3
166 430 412.8