Topic: Employee Salary with Bonus Calculation C Plus Plus Program

Write a C++ program to calculate Net Pay of an employee on the basis of grade. If the empployee has a grade greater than or equal to 17, then he / she will get 60% bunus on the basic pay. Otherwise, the employee will get 30% bonus on his / her basic pay.

This C++ program uses a simple if else statement with comparison operators to perform the above given task.

## Employee Salary with Bonus Calculation C++

### How this Program works?

- First of all the user will input salary of the employee along with grade.
- Now we use the if-else statement to determine that the grade is 17 or above.
- If so, we calculate bonus = 60% of salary
- If the grade of the employee is not 17 or above that is grade sixteen or below, then else block will be executed and the bonus will be computed

as bonus = 30 % of salary - In the next step we calculate total salary by the formula:

salary = salary + bonus - Finally, we will use cout to display total salary of the employee.

/* C++ program to input salary and grade. add bonus 60 % for grade 17 or more add bonus 30% otherwise. www.EasyCodeBook.com */ #include<iostream> using namespace std; int main() { float salary,bonus; int grade; cout<<"Enter salary of Employee="; cin>>salary; cout<<"Enter grade="; cin>>grade; if(grade>=17) bonus = salary * 60.0/100.0; else bonus = salary * 30.0/100.0; salary = salary + bonus; cout<<"The Total salary of Employee = "<<salary; return 0; }

Output:

Enter salary of Employee=10000

Enter grade=17

The Total salary of Employee = 16000

Output when grade input is less than grade 17:

Enter salary of Employee=10000

Enter grade=16

The Total salary of Employee = 13000

You may also like:

### Conditional C Programs

The conditional Logic is very important for beginner programmers. Here we will learn the use of if statement, if-else statement, if-else-if statement, nested if statement and switch statemnt.

- Check Both Numbers are Equal if else
- Larger between two variables
- Largest of two numbers using Ternary Operator
- Greatest among 3 using if and Logical Operators
- Largest value among 3 using Ternary Operator
- Find / Check Leap Year
- Even Odd Number
- Even Odd Number using Ternary Operator
- Positive Negative or Zero
- Simple if to check larger number or equal
- Four Function Calculator using switch statement

9,972 total views, 6 views today