Mar
12
Please help tweak my code?
Written by
admin
I need to: Perform payroll calculations within the program
I need to: Print out the results in a text file so it looks 'pretty'
Heres what I have, I got confused wasnt sure if an array was needed? Please help I am stuck. Also getting an error on the 'fprintf' line.
#include
#include
int main(int argc, char *argv) {
char description[ 30 ];
float price, stateTax, federalTax, medicare, socialSec, grossPay, deductions, netPay;
FILE *in_file;
FILE *out_file;
in_file = fopen( "C:\empsdat.txt", "r" );
while( fscanf( in_file, "%s %f", description, &price ) != EOF ) {
}
fclose( in_file );
stateTax = grossPay * .049;
federalTax = grossPay * .1115;
medicare = grossPay * .0145;
socialSec = grossPay * .062;
deductions = socialSec + medicare + federalTax + stateTax;
netPay = grossPay - deductions;
out_file = fopen( "C:\cis126\empRecords.txt","w" );
fprintf ("Employee Number, Employee Name, Hours, Overtime, Rate, Gross, Deductions, Netn")
frintf( "%f %s %f %f %f %f %f %fn", Employee Number, Employee Name, Hours, Overtime, Rate, Gross, Deductions, Net );
system("PAUSE");
return 0;
}
#If you have any other info about this subject , Please add it free.# |