# Thread: Arrays/calculation error... *need Help*

1. ## Arrays/calculation error... *need Help*

Ok. here is the problem.

My program works perfectly fine when the over time is >0 when calculateing gross pay.. But when the ot rate is zero i get some garbage number in my array position for gross pay...

This is the part of my program that does the gross pay/ot .

/* Check for overtime */

if (hours_array[i] > 40)
{
othours_array[i] = hours_array[i] - 40;
otpay_array[i] = othours_array[i] * (wages_array[i] * 1.5f);
}
else othours_array[i] = 0;
/* Calculate gross pay */

gross_array[i] = wages_array[i] * (hours_array[i] - othours_array[i]) + otpay_array[i];

if my calculate gross pay formula off for some reason when ot end up zero? or is it some mechanical issue in arrays? Any help you can provide would be appreciated. If you need more info please let me know

2. did you initialize it to zero somewhere at the top? If not, give that a shot, it SHOULD take care of the problem.

starX
www.axisoftime.com

3. ## nope.. didn't work...

my output comes out like this:

--------------------------------------------------------------
Clock# Wage Hours OT Gross
--------------------------------------------------------------
098401 10.60 51.0 11.0 598.90
526488 9.75 42.5 2.5 426.56
765349 10.50 37.0 0.0 -107373784.00
034645 12.25 45.0 5.0 581.88
127615 8.35 0.0 0.0 -107374176.00

those two negative numbers are the problem... looks like garbage left in the array... just a guess.

Popular pages Recent additions