Sorting issue that I can't figure out

Discussion in 'C++' started by JJohnson1701, Sep 2, 2010.

  1. JJohnson1701

    JJohnson1701 New Member

    Joined:
    Sep 2, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi everyone,

    I've been wracking my brain on some code for the last week, and I've gotten it nearly settled and working, but the sorted salaries doesn't appear to be working right.

    I'm given the following input file:

    Bill O'Reilly h 85 90
    Pepper Potts h 50 70
    Peter Parker h 45 60
    Doctor Who h 65 150
    James Howlett h 80 50
    Leonard McCoy s 0 140000
    Ronald Reagan s 0 505000
    Bruce Campbell s 0 35000
    MaryJane Watson s 0 75000
    Kate Mulgrew s 0 85000

    (I didn't choose the names!) There's 'h' for hourly, 's' for salary, with the hours, then the wage/salary. The problem is that the program doesn't seem to sort salaries correctly. When sorting by salary, I get:


    First Name Last Name Status Overtime Pay Tax Amount Net Pay/Weekly Net Pay/Yearly
    Bill O'Reilly h 6075.00 2902.50 6772.50 352169.99
    Pepper Potts h 1050.00 1155.00 2695.00 140140.00
    Peter Parker h 450.00 855.00 1995.00 103740.00
    Doctor Who h 5625.00 3487.50 8137.50 423149.99
    James Howlett h 3000.00 1500.00 3500.00 182000.00
    Leonard McCoy s 0.00 42000.00 1884.62 98000.00
    Ronald Reagan s 0.00 151500.01 6798.08 353499.99
    Bruce Campbell s 0.00 10500.00 471.15 24500.00
    MaryJane Watson s 0.00 22500.00 1009.62 52500.00
    Kate Mulgrew s 0.00 25500.00 1144.23 59500.00
    Sorted Salaries:
    1960.00Potts
    1960.00Potts
    1960.00Potts
    1960.00Potts
    1960.00Potts
    1960.00Potts
    6772.50O'Reilly
    8137.50Who
    98000.00McCoy
    353499.99Reagan
    Press any key to continue . . .


    As you can see, it's stuck on 'Pepper Potts' for all the hourly employees for some reason, and I can't figure out why!!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice