I am trying to write a program to fiqure out employee's tax percentages from an input file. I figured out how write most of it, but I'm not very good with call by reference functions, so Im really unsure on how to incorporate them into this function. The given functions we are supposed to use are these
Code:
void readFile(int *EmpID, float *hourly, int *hours);
float week2annual(float hourly, int hours);
float findrate(float annual);
I would appreciate some help if anyone has any to offer. Thanks very much.
Code:
/*
Matt
Comp 1200c
Assignment 6
10/26/06
*/
#include <stdio.h>
#define Weeks 52
#define infiledata "assign6in.txt"
#define outfiledata "assign6out.txt"
void readFile(int *EmpID, float *hourly, int *hours);
float week2annual(float hourly, int hours);
float findrate(float annual);
int main (void)
{
/* Establish variables */
FILE *infile
FILE *outfile
float salary, maximum, maxtax;
int maxEmpID;
/* Get information from data file. */
infile = fopen (infiledata, 'r');
/* Assure there is a data file. */
if ( infile == NULL )
printf("Cannot open data file. \n");
/* Read data file. */
else
readFile (*EmpID, *hourly, *hours);
fscanf( infile, "%d %f %f",
&EmpID, &hourly, &hours );
/* Make sentinel value stop the program */
while (EmpID != 0 )
/* Do calculation */
week2annual ( hourly, hours );
salary = hourly * hours * Weeks;
if ( salary > 319101.00 )
tax = 0.35;
else if ( salary > 146750.00 )
tax = 0.33;
else if ( salary > 70350.00 )
tax = 0.28;
else if ( salary > 29050.00 )
tax = 0.25;
else if ( salary > 7150.00 )
tax = 0.15;
else
tax = 0.10;
/* Figure out the maximum taxed employee */
if ( salary > maximum )
maximum = salary;
maxEmpID = EmpID;
maxtax = tax;
fprintf (outfile, "4d% 9.2% 4.2f%", EmpID, salary, tax );
printf("Employee #04d - Salary: $%9.2f - Tax Rate: %4.2f%% n",
EmpID, salary, tax);
fscanf( infile, "%d %f %f", &EmpID, &salary, &tax );
printf("The top employee is: /n" )
printf("Employee #04d - Salary: $%9.2f - Tax Rate: %4.2f%% n",
maxEmpID, maximum, maxtax);
return 0;