Q: Write a C++ Program To Calculate Bonus on Salary Grade Wise
Program Statement: Write a C++ Program to input salary and grade. it applies a 60% bonus to employees of grade 17 or above. It adds a 30% bonus for all employees of grade less than 17.
Salary Bonus C|++ Program |
Source code of Salary Program for Dev C++ and Modern C++ Compilers / IDEs
#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; }
Sample output of Salary Grade Bonus Program
Enter salary of Employee=10000
Enter grade=17
The Total salary of Employee = 16000
--------------------------------
Process exited after 26.75 seconds with return value 0
Press any key to continue . . .
C++ Source Code of Program To Calculate Bonus on Salary for Turbo C++ 3.0 IDE / Compiler
#include<iostream.h>#include<conio.h>
void main()
{
float salary,bonus;
int grade;
clrscr();
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;
getch();
}
Output of Sample Run: Salary Bonus C ++ Program
Calculate Salary with Bonus according to Grade C++ Program |
How Salary Bonus C++ Program Works: Logic
#include<iostream.h> //include header files#include<conio.h>
void main()
{
float salary,bonus;
int grade;
clrscr();
cout<<"Enter salary of Employee=";
cin>>salary; // Enter salary
cout<<"Enter grade=";
cin>>grade; // input grade
// check if grade greater than or equal to 17
if(grade>=17)
bonus = salary * 60.0/100.0; // calculate 60% bonus
else
bonus = salary * 30.0/100.0; // calculate 30% bonus
salary = salary + bonus; // add bonus to salary
// print salary
cout<<"The Total salary of Employee = "<<salary;
//for staying output window until the user presses a key getch();
}
How To Download Portable Python 3 Easily | CS Helpline Youtube Channel
ReplyDeleteSEO - Learn On Page SEO No Experience Required
ReplyDelete