/* Name: Maria Sandoval (CISP 360)Software Change(Modifications) Record Date: 10/26/20 Purpose: Design and implement application to calculate employee pay Date Who What 10/26/20 Maria Sandoval first souce edits */ #include #include #include #define HEADERFORMAT1 “Employee Pay Reg Hrs Gross Fed SSI Net\n” #define HEADERFORMAT2 “Name Rate Ovt Hrs Pay State Defr Pay\n” #define HEADERLINE “————- ——— ————- ————- ——— ——— ———–\n” #define HEADERFORMAT3 “%-21s %6.2f %9.2f %12.2f %10.2f %10.2f %11.2f\n” #define HEADERFORMAT4 “%36.2f %22.2f %10.2f\n” int main ( ) { extern void getOvtGross (float *h, float *ot, float *pr, float *grs); extern float calcFed (float gross, float defr); extern float calcState (float fedTax); extern float calcSSI (float gross, float defr); FILE *wageReport; //change wageReport = fopen (“c:\\__driveexport\\Ass2cReport.txt”, “wt”); //change if (wageReport == NULL) { // ALWAYS in case of file open failure printf(” Report file open request failed …\n”); printf(” Terminating application …\n”); fflush(stdin),getchar(); return -30; } fprintf (wageReport, HEADERFORMAT1); fprintf (wageReport, HEADERFORMAT2); fprintf (wageReport, HEADERLINE); //fclose (wageReport); REMOVE THIS file close: ALWAYS open ONCE, close ONCE … int a; int i = 0; char firstName [20]; //change char lastName [20]; //change float totalPayRate, totalReg, totalOvt, totalGross, totalFed, totalState, totalSSI, totalDefr, totalNet; //change float payRate, hours, ovtHrs, gross, fedTax, stateTax, ssiTax, defr, netPay; //change printf(“Enter the number of empolyees to be reported: “); scanf (“%d”, &a); printf (“\n”); while (a > i) { printf (“First name: “); scanf (“%s”, &firstName); //change printf (“Last name: “); scanf (“%s”, &lastName); //change printf (“Hourly Pay Rate: “); scanf (“%f”, &payRate); //change printf (“Hours worked: “); scanf (“%f”, &hours); //change printf (“Deferred amount: “); scanf (“%f”, &defr); //change strcat (lastName, “,”); strcat (lastName, firstName); if (a > i + 1) { printf (“Next Employee ————–\n”); } printf (“\n”); getOvtGross (&hours, &ovtHrs, &payRate, &gross); fedTax = calcFed (gross, defr); stateTax = calcState (fedTax); ssiTax = calcSSI (gross, defr); netPay = gross – (fedTax + stateTax + ssiTax + defr); //wageReport = fopen (“Assign2c”, “a”); // open once ONLY … fprintf (wageReport, HEADERFORMAT3, lastName, payRate, hours, gross, fedTax, ssiTax, netPay); fprintf (wageReport, HEADERFORMAT4, ovtHrs, stateTax, defr); fprintf (wageReport, “\n”); //fclose (wageReport); // close once ONLY totalPayRate += payRate; totalReg += hours; totalOvt += ovtHrs; totalGross += gross; totalFed += fedTax; totalState += stateTax; totalSSI += ssiTax; totalDefr += defr; totalNet += netPay; i++; ovtHrs = 0; fflush (stdin); } printf(” You processed %2d employees\n”,i); // for console confirmation //wageReport = fopen (“assign2c”, “a”); // open Once only – always above the loop fprintf (wageReport, HEADERFORMAT3, “Totals: “, totalPayRate, totalReg, totalGross, totalFed, totalSSI, totalNet); fprintf (wageReport, HEADERFORMAT4, totalOvt, totalState, totalDefr); fprintf (wageReport, HEADERFORMAT3, “Averages: “, totalPayRate/a, totalReg/a, totalGross/a, totalFed/a, totalSSI/a, totalNet/a); fprintf (wageReport, HEADERFORMAT4, totalOvt/a, totalState/a, totalDefr/a); fclose (wageReport); /*char size (1000); wageReport = fopen (“Assign2c”, “r”); if (!wageReport) return 1; */ fclose (wageReport);*/ // close ONCE only – always beneath the loop fflush(stdin); getchar(); return 0; } /* Name: Maria Sandoval (CISP 360) Date: 10/26/20 Purpose: Design and implement application to calculate taxes Software Change(Modifications) Record Date Who What 10/26/20 Maria Sandoval first souce edits Application Notes */ #define FEDTAXRATE 0.15 #define STATETAXRATE 0.07 #define SSITAXRATE 0.0775 float calcFed (float gross, float defr) { float fedTax = (gross – defr) * FEDTAXRATE; return fedTax; } float calcState (float fedTax) { float stateTax = (fedTax * STATETAXRATE); return stateTax; } float calcSSI (float gross, float defr) { float SSITax = (gross – defr) *SSITAXRATE; return SSITax; } void getOvtGross (float *h, float *ot, float *pr, float *grs) { void calcOvt (float *hrs, float *ovtime); void calcGross (float *hr, float *oth, float *prt, float *grss); calcOvt (&*h, &*ot); calcGross (&*h, &*ot, &*pr, &*grs); } void calcOvt (float *hrs, float *ovtime) { if (*hrs > 40) { *ovtime = *hrs – 40; *hrs = 40; } else { *ovtime = 0; } } void calcGross (float *h, float *ot, float *pr, float *grs) { *grs = (*h * *pr) + (*ot * *pr * 1.5); }
#Sales Offer!| Get upto 25% Off: