A program uses a char variables named department and two double variables named
ID: 3633050 • Letter: A
Question
A program uses a char variables named department and two double variables named salary and raise. The department variables contains one of the following letters( entered in either uppercase or lowercase): A, B, C or D Employees in department A and B are receiving a 2% raise. Employees in department C are receiving a 1.5% raise, and employees in department D are receiving a 3% raise. Using the switch statement, write the c++ code to calculate the appropriate raise amount.Check work
<code>
#include <iostream>
using namespace std;
int main()
{
char department;
double salary;
double raise;
cout << "Enter department (A, B , C , or D): ";
cin >> department;
cout << "Enter employee salary: ";
cin >> salary;
if ( (department== 'A') || (department== 'B') ) {
raise = salary * 0.02;
}
if ( (department== 'C')
{
raise = salary * 0.015;
(department== 'D') )
raise = salary * 0.03;
}
else if (department=='C') {
raise = salary * 0.015;
}
else
raise = 0;
cout << "The calculated raise is $" << raise << endl;
system("pause");
return 0;
}
<code>
Explanation / Answer
please rate - thanks
#include <iostream>
using namespace std;
int main()
{
char department;
double salary;
double raise;
cout << "Enter department (A, B , C , or D): ";
cin >> department;
cout << "Enter employee salary: ";
cin >> salary;
switch(department)
{case 'A':
case 'B': raise = salary * 0.02;
break;
case 'C': raise = salary * 0.015;
break;
case 'D': raise = salary * 0.03;
}
cout << "The calculated raise is $" << raise << endl;
system("pause");
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.