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

Take the program below and add structs to it, store all employeedata in an array

ID: 3619247 • Letter: T

Question

Take the program below and add structs to it, store all employeedata in an array of your structures.

Create a structure for an employee. Load the structure with yourload method, taking the struct as a parameter. Pass the struct toyour print method and adjust your other methods to make use of thestruct.

Use appropriate methods

--------------
#include <stdio.h>
#include<stdlib.h>
#include <conio.h>
#include<string.h>
void input(double[],double[],char[][10]);
void calcpay(double[],double[],double[],double[],double[]);
double calctax(double);
void print(double[],double[],double[],double[],double[],double[],double[],double,char[][10]);
int main()
{int i;
double rate[5], hours[5], tax[5],baseSalary[5],overtimePay[5],grossSalary[5],netPay[5];
double total=0;
char name[5][10];
input(hours,rate,name);
calcpay(hours,rate,baseSalary,overtimePay,grossSalary);
for(i=0;i<5;i++)
    {tax[i]=calctax(grossSalary[i]); //calculatingtax
     netPay[i]=grossSalary[i]-tax[i];//calculating net pay
     total+=grossSalary[i];
     }
print(rate,hours,tax,baseSalary,overtimePay,grossSalary,netPay,total,name);
getch();
return 0;
}
void input(double hours[],double rate[],char name[][10])
{int i;
for(i=0;i<5;i++)
{printf("Enter name: ");
scanf("%s",&name[i]);
printf("Enter hourly rate: ");
scanf("%lf",&rate[i]);
printf("Enter hours worked: ");
scanf("%lf",&hours[i]);
//if the inputs are -1 break out of the loop
if(hours[i]==-1||rate[i]==-1||strcmp(name[i],"-1")==0)
{
exit(0);
}
}


}

void calcpay(double hours[],double rate[],double baseSalary[],
      double overtimePay[],doublegrossSalary[])
{int i;
for(i=0;i<5;i++)
if(hours[i]>40)
{
grossSalary[i]=((hours[i]-40)*(1.5*rate[i])+(rate[i]*40)); //grosspay
baseSalary[i]=rate[i]*40; //base salary incase of overtime
overtimePay[i] = ((hours[i]-40)*(rate[i]*1.5)); //calculatingovertime pay
}
else
{
grossSalary[i]=hours[i]*rate[i];
baseSalary[i]=hours[i]*rate[i];
overtimePay[i] =0;
}
}
double calctax(double gross)
    {return gross*.2;
     }

void print(double rate[],double hours[],double tax[],doublebaseSalary[],
          doubleovertimePay[],double grossSalary[], double netPay[],
          doubletotal,char name[][10])
{int i;
printf(" ");
for(i=0;i<5;i++)
    {printf("Pay to: %s ",name[i]);
     printf("Hourly rate: %.2f ",rate[i]);
     printf("Hours worked:%.2f ",hours[i]);
     printf("Gross Pay:$%.2f ",grossSalary[i]);
     printf("Base Pay:$%.2f ",baseSalary[i]);
     printf("Overtime Pay:$%.2f ",overtimePay[i]);
     printf("Taxes paid: $%.2f ",tax[i]);
     printf("Net Pay:$%.2f ",netPay[i]);
     }
     printf(" Total pay:$%.2f ",total);
}


Explanation / Answer

please rate - thanks hope this is good #include #include #include #include struct employee {char name[10]; double rate; double hours; double tax; double baseSalary; double overtimePay; double grossSalary; double netPay; }person[5]; void input(struct employee[]); void calcpay(struct employee[]); double calctax(struct employee); void print(struct employee[],double); int main() {int i; double total=0; input(person); calcpay(person); for(i=0;i
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