0

Hey, I was wondering how to have Fscanf loop and do multiple calculations for 4 different employee numbers with 4 different hours and 4 different pay rates.

```
#include <stdio.h>
double pay_calc (double hours_worked, double pay_rate)
{
double tax,gross_pay,net_pay;
gross_pay = hours_worked * pay_rate;
if (hours_worked > 40)
gross_pay = hours_worked * (pay_rate *1.5) ;
tax = gross_pay * .03625;
net_pay = gross_pay - tax;
return net_pay;
}
int main()
{
FILE *input;
int employee_number;
double hours_worked, pay_rate;
input = fopen("pay_file.txt", "r");
fscanf (input, "%d", &employee_number);
/*printf ("Enter in hours worked: ");
scanf ("%lf", &hours_worked);*/
fscanf (input, "%lf", &hours_worked);
/*printf ("Enter in pay_rate: ");
scanf ("%lf", &pay_rate);*/
fscanf(input, "%lf", &pay_rate);
fclose(input);
printf ("%d's pay is %lf\n", employee_number,pay_calc(hours_worked, pay_rate));
return 0;
}
```

This is how I set up pay_file.txt

```
101
44
7.50
102
30
6.00
103
40
8.50
105
48
12.00
```

Thanks in advance for any help.