Arrays/calculation error... *need Help*

This is a discussion on Arrays/calculation error... *need Help* within the C Programming forums, part of the General Programming Boards category; Ok. here is the problem. My program works perfectly fine when the over time is >0 when calculateing gross pay.. ...

  1. #1
    Unregistered
    Guest

    Question 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. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    202
    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. #3
    Unregistered
    Guest

    Question 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 subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Testing some code, lots of errors...
    By Sparrowhawk in forum C Programming
    Replies: 48
    Last Post: 12-15-2008, 03:09 AM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  4. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  5. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21