C++ program to input the basic salary of an employee and calculate its Gross salary by using the if-else statement
C program to input the basic salary of an employee and calculate its Gross salary by using the if-else statement.
Write the program according to the following:
Basic Salary <= 10000 : HRA = 20%, DA = 80%
Basic Salary <= 20000 : HRA = 25%, DA = 90%
Basic Salary > 20000 : HRA = 30%, DA = 95%
Dearness Allowance: Dearness Allowance is given out to employees to reduce the impact of inflation on employees.
House Rent Allowance (HRA): For most employees, House Rent Allowance (HRA) is a part of their salary structure.
Gross Salary: Gross Salary is the monthly or yearly salary before any deductions are made from it.
Flowchart of Gross salary program
C++ Source Code of Gross salary program
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
#include<iostream> using namespace std; int main () { int salary,gross,hra,da; cout<<"enter the basic salary of the employee."<<endl; cin>>salary; if(salary<= 10000) { da=salary*20/100; hra=salary*80/100; gross=salary+da+hra; cout<<"the gross salary of the employee is"<<endl<<gross; } if(salary<= 20000) { da=salary*25/100; hra=salary*90/100; gross=salary+da+hra; cout<<"the gross salary of employee is"<<endl<<gross; } else if(salary>20000) { da=salary*30/100; hra=salary*95/100; gross=salary+da+hra; cout<<"the gross salary of employee is"<<endl<<gross; } else { cout<<"you have no salary"<<endl; } } |
Output
enter the basic salary of the employee.
25000
the gross salary of the employee is
56250
SFT (Shamil’s Flow Table )
Are you interested to Read about SFT(Shamil’s Flow Table)?
Calculating salary in a more simple way
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include<iostream> using namespace std; int main () { int Salary,gross,HouseRentAllowance,Dearness_Allowance; cout<<"enter the basic Salary of the employee."<<endl; cin>>Salary; if(Salary<= 20000) { Dearness_Allowance=Salary*20/100; HouseRentAllowance=Salary*80/100; gross=Salary+Dearness_Allowance+HouseRentAllowance; cout<<"the gross salary of the employee is"<<endl<<gross; } else if(Salary>20000) { Dearness_Allowance=Salary*30/100; HouseRentAllowance=Salary*95/100; gross=Salary+Dearness_Allowance+HouseRentAllowance; cout<<"the gross Salary of employee is"<<endl<<gross; } else { cout<<"you have no Salary"<<endl; } } |
Shamil’s Memory Table (SMT) for Gross Salary in C++
C++ Salary program using switch statement
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
#include <iostream> #include <string> using namespace std; int main() { string First_Name; string Last_Name; double Salary; int Rating_Score; int Progress_Bonus; const double BONUS1 = .25; const double BONUS2 = .15; const double BONUS3 = .10; const double NO_BONUS = 0.00; const int RATING1 = 1; const int RATING2 = 2; const int RATING3 = 3; cout << "Enter employee's first name: "; cin >> First_Name; cout << "Enter employee's last name: "; cin >> Last_Name; cout << "Enter employee's yearly salary: "; cin >> Salary; cout << "Enter employee's performance rating: "; cin >> Rating_Score; switch(Progress_Bonus) { case RATING1 : Salary * BONUS1; break; case RATING2 : Salary * BONUS2; break; case RATING3 : Salary * BONUS3; break; default : cout << NO_BONUS << endl; break; } cout << "Employee Name: " << First_Name << " " << Last_Name << endl; cout << "Employee Salary: $" << Salary << endl; cout << "Employee Rating: " << Rating_Score << endl; cout << "Employee Bonus: $" << Progress_Bonus << endl; return 0; } |
Output
Enter employee’s first name: ali
Enter employee’s last name: khan
Enter employee’s yearly salary: 800000
Enter employee’s performance rating: 1
0
Employee Name: ali khan
Employee Salary: $800000
Employee Rating: 1
Employee Bonus: $-1
——————————–
C++ Exercise | If else Statement
- calculate the bill
- character is small, capital or a special character
- a number is even or odd
- 0 is a positive or negative number
- a positive and negative number
- Enter Range of numbers and replaced them
- a greater number among three numbers
- Armstrong Number
- ASCII codeÂ
- Find the Maximum value program in C++ (C Plus Plus).
- maximum number
- Maximum Number between two numbersÂ
- Student Grade
- the number is divisible by 11 or 5 or not
- TriangleÂ
- a triangle is an equilateral, isosceles or scalene
- Leap yearÂ
- character is an alphabet or not
- Grade Percentage
- character is an alphabet, digit, or special character
- character is an uppercase or lowercase.
- Weekdays
- a prime or composite number
- hours and minutes as AM or PM
- swap the values of two numbers
- update even to odd
- Profit Loss
- centimeter into meter and kilometerÂ
- TriangleÂ
- Salary
- Even odd with goto statement.
- area of the circle