Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The program that calculates the simple weekly payroll for up to 20 employees. Th

ID: 3732299 • Letter: T

Question

The program that calculates the simple weekly payroll for up to 20 employees. The app will prompt for employee name, hourly rate and number of hours worked. It will then calculate for gross pay (hourly rate * number of hours worked), withholding tax deduction (gross pay * 5%), social security deduction (gross pay * 3%), and medicare deduction (gross pay * 1%). The payroll report will show the calculation for each employee and the cumulative totals. Example: How many employees to process? 2 1 Enter name: John 1 Enter hourly rate: 15.75 1 Enter number of hours worked: 35 2 Enter name: Maria 2 Enter hourly rate: 20.00 2 Enter number of hours worked: 40 Employee: rate: hours: Gross: W/T: SS: Med: Net: John 15.75 35 551.25 27.56 16.54 5.51 501.64 Maria 20 40 800 40 24 8 728 Total 75 1,351.25 67.56 40.54 13.51 1,239.64

This needs to be in c++.

Explanation / Answer

#include <iostream>
#include <iomanip>
#include <locale>
using namespace std;

int main() {
int i,n;
string name[20];

locale::global(locale("")); // set user prefered local

cout.imbue(std::locale());// use the new global locale with cout

double hourlyRate[20],hours[20],grossPay[20],withholdingTax[20],ssDed[20],medDed[20],netPay[20];
double totalHours,totalGrossPay,totalWt,totalSS,totalNetPay;

totalHours=totalGrossPay=totalWt=totalSS=totalNetPay=0;

cout<<fixed<<setprecision(2); //2 decimal places

cout<<"How many employees to process? ";
cin>>n;


for(i=0;i<n;i++)
{
cout<<" "<<i+1<<"Enter name: ";
cin>>name[i];
cout<<" "<<i+1<<"Enter hourly rate: ";
cin>>hourlyRate[i];
cout<<" "<<i+1<<"Enter number of hours worked: ";
cin>>hours[i];
grossPay[i] = hourlyRate[i] * hours[i];
withholdingTax[i] = grossPay[i] * 0.05;
ssDed[i] = grossPay[i] * 0.03;
medDed[i] = grossPay[i] * 0.01;
netPay[i] = grossPay[i]-withholdingTax[i]-ssDed[i]-medDed[i];

totalHours = totalHours + hours[i];
totalGrossPay = totalGrossPay +grossPay[i];
totalWt = totalWt + withholdingTax[i];
totalSS = totalSS + ssDed[i];
totalNetPay = totalNetPay + netPay[i];

}


   cout<<" Employee: rate: hours: Gross: W/T: SS: Med: Net:";
  
for(i=0;i<n;i++)
{
   cout<<" "<<name[i]<<" "<<hourlyRate[i]<<" "<<hours[i]<<" "<<grossPay[i]<<" ";
   cout<<withholdingTax[i]<<" "<<ssDed[i]<<" "<<medDed[i]<<" "<<netPay[i];
}
  
   cout<<" Total "<<totalHours<<" "<<totalGrossPay<<" "<<totalWt<<" "<<totalSS<<" "<<totalNetPay;
return 0;
}

output:

How many employees to process?2
1Enter name:John
1Enter hourly rate:15.75
1Enter number of hours worked:35
2Enter name:Maria
2Enter hourly rate:20.00
2Enter number of hours worked: 40

Employee: rate: hours: Gross: W/T: SS: Med: Net:
John 15.75 35.00 551.25 27.56 16.54 5.51 501.64
Maria 20.00 40.00 800.00 40.00 24.00 8.00 728.00
Total 75.00 1,351.25 67.56 40.54 1,229.64

Do ask if any query. Please upvote if the answer is useful.