Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Having a small bit of trouble

  • 15-02-2005 09:56PM
    #1
    Registered Users, Registered Users 2 Posts: 6,658 ✭✭✭


    I have to write a program. Input Employee Num, Name, and their Salary
    up to 20000euro 7% Bonus
    between 20.000 and 30.000 5.5%
    30.000 and 40.000 4%
    and over 40.000 3.5

    Need to output Name, employee Num, Bonus and Adjusted salary with Bonus added.

    Now this is what i have writen but havin problem,
    When entering the Name and when i enter the Salary it always comes up 0% com?

    Can someone tell me what i'm doing wrong?


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Can someone tell me what i'm doing wrong?
    What you're doing wrong is you've not asked for help on a specific issue. You've just attached your code (not even specifying the language) and expect us to debug / write it for you.

    And guess what, no one wants to do your homework for you.


  • Registered Users, Registered Users 2 Posts: 6,658 ✭✭✭PowerHouseDan


    sorry,the issue in question is when i enter a name in letter the programs closes i can only use numbers and my if statement when i enter a salary ie 25000 the commission comes up as 0%. Dont expect anyone to write it.Sorry its c++


  • Registered Users, Registered Users 2 Posts: 6,651 ✭✭✭daymobrew


    when i enter a name in letter the programs closes
    Change
    int name;
    to
    char name[50];

    Not sure about the if/else comparison stuff, I can't remember how float comparisons work. You could cheat and change 'sales' to int.


  • Registered Users, Registered Users 2 Posts: 6,658 ✭✭✭PowerHouseDan


    Yeah i dont know why i had it set as a float in the First Place. Even if i put sales as a int, It still wont work out the Bonus?that the only thing thats getting me.


  • Registered Users, Registered Users 2 Posts: 6,651 ✭✭✭daymobrew


    I think the problem is with:
    if (sales >40000)
        comm = sales *.3;
    else
    {
        comm=0;
        cout<<"You do not have enough commission"<<endl;
    }
    
    because, unless sales is above 40000, it will fall into the 'else' and report not enough commission.
    Do it in reverse: check if above 40k, else if above 30k else etc etc.
    The final else will be comm = sales * 0.7;

    If you had put cout lines in each if block you would have seen the program enter the correct code only to fall in to the 'not enough commission' block.


  • Advertisement
Advertisement