C++ Switch Case Statement Program Page 188 number 7
/****JDS***********************
DATE : 3/15/2022
CREATED BY: James Strickland
CLASS : IT-301 - Intro to Programming
PURPOSE : Switch Statement, employee
program.
****JDS***********************/
#include
#include
#include
#include
using namespace std;
int main() {
char department;
double salary = 0.0;
double raise_amount = 0.0;
do { // start a do - while loop
// "start" screen, menu
cout << " +--+--+--+--+--+--+--+--+--+--+" << endl;
cout << " |D|e|p|a|r|t|m|e|n|t|" << endl;
cout << " +--+--+--+--+--+--+--+--+--+--+" << endl << endl;
cout << " Departments list" << endl;
cout << "\t Department A" << endl;
cout << "\t Department B" << endl;
cout << "\t Department C" << endl;
cout << "\t Department D" << endl;
cout << "Please enter Deptartment A, B, C, D [Q to quit]: "; cin >> department; // get user input
switch (department) { // begin switch statement
case 'a': case 'A':
case 'b': case 'B':
cout << "Enter salary of the employee: "; cin >> salary;
raise_amount = (salary * 0.02);
cout << "Raise amount: ";
cout << setprecision(2) << fixed << raise_amount << endl;
system("pause");
cout << "\033[2J\033[1;1H";
break;
case 'c': case 'C':
cout << "Enter salary of the employee: "; cin >> salary;
raise_amount = (salary * 0.15);
cout << "Raise amount: ";
cout << setprecision(2) << fixed << raise_amount << endl;
system("pause");
cout << "\033[2J\033[1;1H";
break;
case 'd': case 'D':
cout << "Enter salary of the employee: "; cin >> salary;
raise_amount = (salary * 0.03);
cout << "Raise amount: ";
cout << setprecision(2) << fixed << raise_amount << endl;
system("pause");
cout << "\033[2J\033[1;1H";
break;
default:
cout << "Invalid Selection. " << endl;
cout << "\033[2J\033[1;1H";
break;
} // end switch statement
} while (!((department == 'Q') || (department == 'q'))); // last of the do-while loop. Q or q break from loop.
system("pause");
return 0;
} // main bracket