Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Having a small bit of trouble

  • 15-02-2005 8:56pm
    #1
    Registered Users, Registered Users 2 Posts: 6,659 ✭✭✭


    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,659 ✭✭✭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,571 ✭✭✭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,659 ✭✭✭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,571 ✭✭✭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