A program uses a char variable named department and two double variables named salary and raise. The department variable contains one of the following letters (entered in either uppercase or lowercase): A, B, or C. Employees in departments A and B will receive a 2% raise. Employees in department C will receive a 1.5% raise. Write a C++ program to calculate and display the appropriate raise amount. Display the raise amount in fixed-point notation with two decimal places.
Here is the Solution to the problem above:
#include <iomanip>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
char department;
double salary;
double raise;
cout<<"Enter the employee's department: ";
cin>>department;
cout<<"Enter the employee's salery: ";
cin>>salary;
if(department == 'A'||department == 'a')
{
raise = salary/100*2;
}
else if(department == 'B'||department == 'b')
{
raise = salary/100*2;
}
else if(department == 'C'||department == 'c')
{
raise = salary/100*1.5;
}
cout<<"Employee's pay raise by: ";
cout << setprecision(2) << fixed << raise;
return 0;
}