Site icon T4Tutorials.com

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

Flowchart-of-C-program-to-input-the-basic-salary-of-an-employee-and-calculate-its-Gross-salary-by-using-the-if-else-statement
Flowchart-of-C-program-to-input-the-basic-salary-of-an-employee-and-calculate-its-Gross-salary-by-using-the-if-else-statement

C++ Source Code of Gross salary program

#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)?

YouTube video player

Calculating salary in a more simple way

#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++

write a C++ program to calculate gross salary
write a C++ program to calculate gross salary
c++ program employee salary
c++ program employee salary

C++ Salary program using switch statement

#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

  1. calculate the bill
  2. character is small, capital or a special character
  3. a number is even or odd
  4. 0 is a positive or negative number
  5. a positive and negative number
  6. Enter Range of numbers and replaced them
  7. a greater number among three numbers
  8. Armstrong Number
  9. ASCII code 
  10. Find the Maximum value program in C++ (C Plus Plus).
  11. maximum number
  12. Maximum Number between two numbers 
  13. Student Grade
  14. the number is divisible by 11 or 5 or not
  15. Triangle 
  16. a triangle is an equilateral, isosceles or scalene
  17. Leap year 
  18. character is an alphabet or not
  19. Grade Percentage
  20. character is an alphabet, digit, or special character
  21. character is an uppercase or lowercase.
  22. Weekdays
  23. a prime or composite number
  24. hours and minutes as  AM or PM
  25. swap the values of two numbers
  26. update even to odd
  27. Profit Loss
  28. centimeter into meter and kilometer 
  29. Triangle 
  30. Salary
  31. Even odd with goto statement.
  32. area of the circle

shamil memory table

Exit mobile version