Answer to Question #171349 in C++ for Jack

Question #171349

Make a loop for a different number of years and stop in years worth enter as 0, 99 or higher or negative numbers Prompt the user for the salary per year and calculate the Christmas bonus based on the number of years work as follow for 1 to 5 years 1% of gross pay, and six or more years to percent of gross pay


1
Expert's answer
2021-03-13T10:10:53-0500
#include <iostream>




using namespace std;




int main()
{   int gpay, years, bonus;
    
    while (1)
    {
        cout<<"Enter your gross pay :";
        cin>>gpay;
        cout<<"Enter number of years of work :";
        cin>>years;
        
        if ( years > 0 && years < 5) 
        {
            bonus = gpay*0.1; 
           cout<<"Your Christmas Bonus is : "<<bonus;
           break;
        }
           
        else if (years > 5 && years < 99)
        {
            bonus = gpay*0.2;
            cout<<"Your Christmas Bonus is : "<<bonus;
            break;
        }
        
        else if (years < 0 || years > 99)
        {    
            cout<<"Please enter years between 0 or 99"<< endl;
            continue;
            
        }
    }
    
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS