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

For C++ program usind DEVC++ I have first a payroll program that I have made and

ID: 3831668 • Letter: F

Question

For C++ program usind DEVC++ I have first a payroll program that I have made and the second program is a trial run of a program that I need to include/add to the first program. Not sure where to imput the information in the program. Any help would be greatly appreciated!!!!

#include<iostream>
#include<iomanip>

using namespace std;

main(){
char employeeid[100][10];
char firstname[100][15], lastname[100][15];
char maritalstatus[100];
double hourlyrate[100], grosspay[100], netpay[100], taxrate[100], maritalrate[100], taxamount[100], regularpay[100], overtimepay[100];
int hoursworked[100], overtimehours[100];
int counter = 0;
int i;
  
cout<<"ENTER EMPLOYEE ID, MARITAL STATUS(S,M,H), FIRST NAME, LAST NAME, HOURS WORKED, HOURLY RATE"<<endl;
cout<<"ctrl z to end"<<endl;
while(cin>>employeeid[counter]>>maritalstatus[counter]>>firstname[counter]>>lastname[counter]>>hoursworked[counter]>>hourlyrate[counter])
counter = counter+1;
for(i=0;i<counter;i++){ //loop for overtimepay
if (hoursworked[i] > 40) overtimehours[i] = (hoursworked[i] - 40);
overtimepay[i] = overtimehours[i] * (hourlyrate[i] * 1.5);
if (hoursworked[i] < 40) overtimepay[i] = 0;}
for(i=0;i<counter;i++){ //loop for grosspay
grosspay[i] =(hoursworked[i] * hourlyrate[i]) + overtimepay[i];
regularpay[i] = (grosspay[i] - overtimepay[i]);}
for(i=0;i<counter;i++){ //loop for taxrate depending on grosspay
if(grosspay[i] > 1000) taxrate[i] = 0.30;
else if(grosspay[i] > 800) taxrate[i] = 0.20;
else if(grosspay[i] > 500) taxrate[i] = 0.10;
else if(grosspay[i] >= 0) taxrate[i] = 0.0;}
for(i=0;i<counter;i++){ //loop formaritalrate=taxrate +/- depending on marital status
if(maritalstatus[i] == 'S') maritalrate[i] += 0.05;
else if(maritalstatus[i] == 'H') maritalrate[i] -= 0.05;
else taxrate[i];}
for(i=0;i<counter;i++){ //loop for taxamount
taxamount[i] = (grosspay[i] * (taxrate[i] + maritalrate[i]));}
for(i=0;i<counter;i++){ //loop for netpay
netpay[i] = grosspay[i] - taxamount[i];}
cout<<endl;
  
cout<<"X-Men's Payroll'"<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<setw(15), setprecision(1),setiosflags(ios::fixed|ios::showpoint|ios::left);   
cout<<"EMPLOYEE ID"<<setw(14)<<"MARTIAL STATUS"<<setw(12)<<"FIRST NAME"<<setw(12)<<"LAST NAME"
<<setw(6)<<"HOURS WORKED"<<setw(6)<<"HOURLY RATE"<<setw(6)<<"OVERTIME HOURS"<<setw(6)<<"OVERTIME PAY"<<setw(6)<<"REGULAR PAY"<<setw(7)<<"GROSS PAY"<<setw(6)<<"TAXAMOUNT"<<setw(6)<<"NET PAY"<<endl;
for(i=0;i<counter;i++){
cout<<setw(15), setprecision(1),setiosflags(ios::fixed|ios::showpoint|ios::left);
cout<<employeeid[i]<<setw(14)<<maritalstatus[i]<<setw(12)<<firstname[i]<<setw(12)<<lastname[i]
<<setw(6)<<hoursworked[i]<<setw(6)<<hourlyrate[i]<<setw(6)<<overtimehours[i]<<setw(6)<<overtimepay[i]<<setw(6)<<regularpay[i]<<setw(7)<<grosspay[i]<<setw(6)<<taxamount[i]<<setw(6)<<netpay[i]<<endl;
}
return 0;
}//MAIN

ran another sample program for finding the average netpay but it now needs to be added to the previous one: the sample program is:

#include <iostream>
using namespace std;
//external variables
float employeenetpay1, employeenetpay2, employeenetpay3, employeenetpay4, employeenetpay5;
//function prototypes
void readnumbers(void);
float findsum(float, float, float, float, float);
float findaverage(float);
void printall(float, float, float, float, float, float, float);
int main(){
   float sum;
   float average;
   readnumbers();
   sum=findsum(employeenetpay1, employeenetpay2, employeenetpay3, employeenetpay4, employeenetpay5);
   average=(findaverage(sum));
   printall(employeenetpay1, employeenetpay2, employeenetpay3, employeenetpay4, employeenetpay5, sum, average);
   return 0;
}//MAIN
//function definitions
void readnumbers(void){
cout<<"ENTER FIVE SEPARATE EMPLOYEENETPAYS:";
cin>>employeenetpay1>>employeenetpay2>>employeenetpay3>>employeenetpay4>>employeenetpay5;
}//READNUMBERS
float findsum(float employeenetpay1, float employeenetpay2, float employeenetpay3, float employeenetpay4, float employeenetpay5){
float sum;
sum=employeenetpay1+employeenetpay2+employeenetpay3+employeenetpay4+employeenetpay5;
return sum;
}//FINDSUM
float findaverage(float sum){
float average;
average=sum/5.0;
return average;
}//FINDAVERAGE
void printall(float employeenetpay1, float employeenetpay2, float employeenetpay3,
   float employeenetpay4, float employeenetpay5, float sum, float average){
cout<<"EMPLOYEE 1 NETPAY IS:"<<employeenetpay1<<endl;
cout<<"EMPLOYEE 2 NETPAY IS:"<<employeenetpay2<<endl;
cout<<"EMPLOYEE 3 NETPAY IS:"<<employeenetpay3<<endl;
cout<<"EMPLOYEE 4 NETPAY IS:"<<employeenetpay4<<endl;
cout<<"EMPLOYEE 5 NETPAY IS:"<<employeenetpay5<<endl;
cout<<"THE NETPAY SUM IS:"<<sum<<endl;
cout<<"THE NETPAY AVERAGE IS:"<<average<<endl;
}//PRINTALL
//end source code

Explanation / Answer

//the program now calculates net pay sum and net pay average and displays it

#include<iostream>
#include<iomanip>

using namespace std;

main(){
char employeeid[100][10];
char firstname[100][15], lastname[100][15];
char maritalstatus[100];
double hourlyrate[100], grosspay[100], netpay[100], taxrate[100], maritalrate[100], taxamount[100], regularpay[100], overtimepay[100];
int hoursworked[100], overtimehours[100];
int counter = 0;
int i,netpaySUM=0;
           double netPayAVG;
  
cout<<"ENTER EMPLOYEE ID, MARITAL STATUS(S,M,H), FIRST NAME, LAST NAME, HOURS WORKED, HOURLY RATE"<<endl;
cout<<"ctrl z to end"<<endl;
while(cin>>employeeid[counter]>>maritalstatus[counter]>>firstname[counter]>>lastname[counter]>>hoursworked[counter]>>hourlyrate[counter])
counter = counter+1;
for(i=0;i<counter;i++){ //loop for overtimepay
if (hoursworked[i] > 40) overtimehours[i] = (hoursworked[i] - 40);
overtimepay[i] = overtimehours[i] * (hourlyrate[i] * 1.5);
if (hoursworked[i] < 40) overtimepay[i] = 0;}
for(i=0;i<counter;i++){ //loop for grosspay
grosspay[i] =(hoursworked[i] * hourlyrate[i]) + overtimepay[i];
regularpay[i] = (grosspay[i] - overtimepay[i]);}
for(i=0;i<counter;i++){ //loop for taxrate depending on grosspay
if(grosspay[i] > 1000) taxrate[i] = 0.30;
else if(grosspay[i] > 800) taxrate[i] = 0.20;
else if(grosspay[i] > 500) taxrate[i] = 0.10;
else if(grosspay[i] >= 0) taxrate[i] = 0.0;}
for(i=0;i<counter;i++){ //loop formaritalrate=taxrate +/- depending on marital status
if(maritalstatus[i] == 'S') maritalrate[i] += 0.05;
else if(maritalstatus[i] == 'H') maritalrate[i] -= 0.05;
else taxrate[i];}
for(i=0;i<counter;i++){ //loop for taxamount
taxamount[i] = (grosspay[i] * (taxrate[i] + maritalrate[i]));}
for(i=0;i<counter;i++){ //loop for netpay
netpay[i] = grosspay[i] - taxamount[i];
netpaySUM=netpaySUM+netpay[i];                          
                           }
cout<<endl;
netPayAVG=netpaySUM/counter;
  
cout<<"X-Men's Payroll'"<<endl;
cout<<" "<<endl;
cout<<" "<<endl;
cout<<setw(15), setprecision(1),setiosflags(ios::fixed|ios::showpoint|ios::left);   
cout<<"EMPLOYEE ID"<<setw(14)<<"MARTIAL STATUS"<<setw(12)<<"FIRST NAME"<<setw(12)<<"LAST NAME"
<<setw(6)<<"HOURS WORKED"<<setw(6)<<"HOURLY RATE"<<setw(6)<<"OVERTIME HOURS"<<setw(6)<<"OVERTIME PAY"<<setw(6)<<"REGULAR PAY"<<setw(7)<<"GROSS PAY"<<setw(6)<<"TAXAMOUNT"<<setw(6)<<"NET PAY"<<endl;
for(i=0;i<counter;i++){
cout<<setw(15), setprecision(1),setiosflags(ios::fixed|ios::showpoint|ios::left);
cout<<employeeid[i]<<setw(14)<<maritalstatus[i]<<setw(12)<<firstname[i]<<setw(12)<<lastname[i]
<<setw(6)<<hoursworked[i]<<setw(6)<<hourlyrate[i]<<setw(6)<<overtimehours[i]<<setw(6)<<overtimepay[i]<<setw(6)<<regularpay[i]<<setw(7)<<grosspay[i]<<setw(6)<<taxamount[i]<<setw(6)<<netpay[i]<<endl;
}
cout<<" Net pay sum is "<<netpaySUM;
cout<<" Net pay average is "<<netPayAVG;
return 0;
}//MAIN

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote