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

Write a program to process weekly employee time cards for all employees of an or

ID: 3623206 • Letter: W

Question

Write a program to process weekly employee time cards for all employees of an organization. Each employee will have three data items: an identification number, the hourly wage rate, and the number of hours worked during a given week. Each employee is to be paid time and a half for all hours worked over 40. A tax amount of 3.625 percent of gross salary will be deducted. The program output should show the employee’s number and net pay. Display the total payroll and the average amount paid at the end of the run.
1. Read data from a file (employee.txt).
2. Use end-of-file test to end reading data.
3. Create a function to calculate the net pay for each employee.
4. Call the previous function from main
5. Display employee number and pay
6. Display the total payroll and the average amount paid at the end of the run

Use the library function fprintf to write data to a text file (instead of using printf to write it to the display).
Use fscanf to read data from a file (instead of using scanf to read it from the keyboard).
When opening the file with fopen, open the file for reading instead of writing, change the second parameter of fopen from “w” to “r”. Compare the file pointer to see if it has the value NULL, which (in this case) probably means that the filename given as the first parameter to fopen was incorrect.

Explanation / Answer

please rate - thanks

#include <stdio.h>
#include <conio.h>
double netpay(double,double);
int main()
{int num,count=0;
double rate, hours, net, total=0,average;
FILE *input,*output;

input = fopen("employee.txt","r");
if(input == NULL)
{ printf("Error opening input file 1! ");
    return 0;
   }
output = fopen("output.txt","w");
fprintf(output," Employee Number Pay ");
while(fscanf(input,"%d",&num)>0)
    {fscanf(input,"%lf",&rate);
     fscanf(input,"%lf",&hours);
     net=netpay(rate,hours);
     total+=net;
     count++;
     fprintf(output,"%d $%.2f ",num,net);
     }
fprintf(output,"Total payroll $%.2f Average pay $%.2f ",total,total/count);
fclose(input);
fclose(output);                          

return 0;
       
}

double netpay(double rate, double hours)
    {double pay,gross;
     if(hours>40)
          gross=rate*40+(hours-40)*(rate*1.5);
     else
          gross=rate*hours;
     pay=gross-.03625*gross;
     return pay;
     }    
   

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