This is the problem, when I run it, there are no errors. However when I check the reportfile, I end up with the wrong numbers from the calculations.
The calculator:
void AddDetailToAccumulators(float *totfedtax, float *totssitax, float *totstatetax,float *totrate, float *totreg,
float *totovt, float *totgross,float *totpay,float *totdeferred, float gross, float federaltax, float statetax,
float ssitax,float hours, float payrate,float deferred,float reghrs,float ovthrs,float netpay,float *avgfedtax, float *avgssitax, float *avgstatetax,float *avgrate, float *avgreg,
float *avgovt, float *avggross,float *avgpay,float *avgdeferred)
{
*totfedtax+=federaltax;
*totstatetax+=statetax;
*totssitax+=ssitax;
*totrate+=payrate;
*totdeferred+=deferred;
*totreg+=reghrs;
*totovt+=ovthrs;
*totgross+=gross;
*totpay+=netpay;
*avgfedtax=*totfedtax/MAX;
*avgstatetax=*totstatetax/MAX;
*avgssitax=*totssitax/MAX;
*avgrate=*totrate/MAX;
*avgdeferred=*totdeferred/MAX;
*avgreg=*totreg/MAX;
*avgovt=*totovt/MAX;
*avggross=*totgross/MAX;
*avgpay=*totpay/MAX;
}
The printer file
void Print_Summary_To_File(float totfedtax, float totssitax, float totstatetax,float totrate, float totreg,
float totovt, float totgross,float totpay,float totdeferred,float avgfedtax, float avgssitax,
float avgstatetax,float avgrate, float avgreg,
float avgovt, float avggross,float avgpay,float avgdeferred,FILE *reportfile)
{
fprintf(reportfile, "%16s%15.2f%9.2f%9.2f%9.2f",
"Totals", totrate, totreg, totgross, totfedtax);
fprintf(reportfile, "%8.2f%9.2f \n%40.2f%18.2f%8.2f\n\n",
totssitax, totpay, totovt,totstatetax, totdeferred);
fprintf(reportfile, "%18s%13.2f%9.2f%9.2f%9.2f",
"Averages", avgrate, avgreg, avggross, avgfedtax);
fprintf(reportfile, "%8.2f%9.2f \n%40.2f%18.2f%8.2f\n\n\n\n\n\n",
avgssitax, avgpay, avgovt, avgstatetax, avgdeferred);
}
What was printed on reportfile:
Employee Pay Reg Hrs Gross Fed SSI Net
Name Rate Ovt Hrs Pay State Defr Pay
================= ===== ======= ======= ======= ====== ======
Doe, John 17.00 40.00 845.75 119.36 61.67 606.36
6.50 8.36 50.00Whittle, Ed 11.50 25.50 293.25 43.99 22.73 223.46
0.00 3.08 0.00Marion, Louise 13.00 40.00 520.00 63.00 32.55 320.04
0.00 4.41 100.00Prentiss, Paula 15.75 40.00 878.06 112.96 58.36 573.83
10.50 7.91 125.00Davidson, Carl 8.75 38.00 332.50 47.63 24.61 241.93
0.00 3.33 15.00Totals -107374112.00-107373992.00-107371296.00-107373792.00-107373976.00-107372208.00
-107374160.00 -107374152.00-107373888.00Averages -21474822.00-21474798.00-21474260.00-21474758.00-21474796.00-21474442.00
-21474832.00 -21474830.00-21474778.00
The 'Totals' and 'Averages' section are completely out of whack. I'm guessing is a Print_Summary_To_File problem.