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

Each week, a payroll program collects information from company employees to calc

ID: 653816 • Letter: E

Question

Each week, a payroll program collects information from company employees to calculate weekly paychecks and generate the payroll report.

Input format

3 pieces of information are required for each employee:

? employee ID

? employee type, to identify hourly, piecework or commission employees

? either number of hours worked, number of items produced, or weekly sales in $,

determined by employee type as explained below

Output required

Output from the program will be a well-formatted table, with a line for each employee.

Summary information reporting the total of all net pay is required at the foot of the table,

as shown. The first few and last few lines will be:

ID Gross Penalty Tax Net Comment

-- ----- ------- --- --- -------

10 1000.00 0.00 70.00 930.00 Overtime

20 800.00 0.00 56.00 744.00

. . .

. . .

80 600.00 0.00 42.00 558.00

90 600.00 50.00 38.50 511.50 Low sales

Total net: 5115.00

How to calculate gross, penalty and comment for the table

Hourly employees

? input: number of hours worked

? gross pay: pay rate is $20/hour for any number of hours worked

penalty: (none)

? comment: output

Explanation / Answer

#include <stdio.h>
#include <stdlib.h>
void initialize(double *totalNet);
void printHeader(void);
void hourly(int id, double hours, double *totalNet);
void piecework(int id, double sales, double *totalNet);
void calcTaxNet(double grossPay, double penalty, double *tax,
double *netPay);
void printSummary(double totalNet);
void main(void)
{
char type; // employee type
int id; // employee ID
double num, // employee productivity info
totalNet;
FILE *fp;
errno_t err;
initialize(&totalNet);
err = fopen_s(&fp, "Payroll.dat", "r"); // open the data file
if (err != 0) {
printf("File not found. ");
exit(1);
}
void printHeader()
{
while (!feof(fp))
{
fscanf_s(fp, "%d", &id);
fscanf_s(fp, " %c", &type, 1);
fscanf_s(fp, " %lf", &num);
if (type == 'H')
else if (type == 'P')
}
void hourly(int id, double hours, double *totalNet)
{
double gross, pen, tax, net;
gross = hours*20.0;
pen=0.0;
tax=gross*0.07;
net=gross-pen-tax;
*totalNet+=net;

if(hours>40)
printf("%d %lf %lf %lf %lf Overtime ", id, gross, pen, tax, net);
else
printf("%d %lf %lf %lf %lf ", id, gross, pen, tax, net);
}
void piecework(int id, double sales, double *totalNet)
{
int lowSales = FALSE;
double penalty, grossPay, tax, netPay;
penalty = 0.0;
grossPay = sales * PIECE_NUM_SALES; //calculating gross pay, num of items sold * 15
if(sales < 30)
{
lowSales = TRUE;
penalty = PIECE_NUM_SALES_LOW * sales; //5 * num of items sold
}
calcTaxNet(grossPay, penalty, &tax, &netPay);
*totalNet += netPay;
if(lowSales)
printf("%3d%10.2lf%12.2lf%15.2lf%18.2lf%20s ", id, grossPay, penalty, tax, netPay, "Low Production");
else
  
printf("%3d%10.2lf%12.2lf%15.2lf%18.2lf%20s ", id, grossPay, penalty, tax, netPay, "");

}
void calcTaxNet(double grossPay, double penalty, double *tax, double *netPay)
{
*tax = TAX_RATE * (grossPay - penalty);
*netPay = grossPay - (penalty + *tax);
}
void printSummary(double totalNet)
{
printf(" %.2lf ", totalNet);
}

}

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