Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to modify a program I already wrote to evaluate a \"Union code\" A,B or C

ID: 3541994 • Letter: I

Question

I have to modify a program I already wrote to evaluate a "Union code" A,B or C in a while loop. The program I am modifying already has the code being evaluated by a switch statement. How do I get my switch statement to function properly inside of a while loop??? I tried all night until I fell asleep from looking at the screen with no more fresh ideas. Help would be appreciated.




[code]

#include <iostream>


#include <string>


#include <vector>


#include <iomanip>


#include <cmath>


#include <algorithm>

#include<conio.h>

using namespace std ;


int main ()


{


vector<string>Names;

vector<double>Hours;

vector<double>Payrate;

vector<char>Union;

vector<double>Uniondues;


double dues;

char code;

double hrs;

double grade;


string EmID;




cout<<" Work flow is a profitable practice.   "<<

" Let's get these folks paid!! ";





for (int i= 0;i<3;i++)


{ cout<<  " Enter the students name. ";

cin>>EmID;

Names.push_back(EmID);



cout<< "Hours worked?";


cin>>hrs;


while

(hrs<0 || hrs>=60)

{(cout<<  "Hours exceed Maxium Allowable work Hours.    Child labor pentalities may result.   P.S..  YOUR FIRED!!!!    ")

;

cout<< " ";

cout<< " ";



cout<< " .. Enter Hours worked.";

cin>>hrs;}


Hours.push_back(hrs);




cout<< " Enter employee payrate. ";

cin >> grade;


while

(grade<7.50 || grade>45.00)

{(cout<<  "Payrate not withing Allowable Range.");

cout<< " ";

cout<< " ";


cout<< " .. Enter Valid Payrate.";

cin>>hrs;}

Payrate.push_back(grade);




cout<< "what is code?";

cin>> code;


while (cin>>code)


{  switch (code)



{ case 'A': case 'a':

dues= 25.00;


        break;

case 'B' : case 'b':

dues= 50.00;


break;


case 'C' : case 'c':

dues= 75.00;


break;


default:


cout<<" Inputted union code is invalid. ";

cout<<" Enter valid Union Code ";

cin>>code;

// loop

continue;


}}


Union.push_back(code);

Uniondues.push_back(dues);



}











// print names


for (int i= 0; i<3; i++)

{

cout<<Names[i]<<endl;

cout<<Hours[i]<<endl;

cout<<Uniondues[i]<<endl;

}


system ("pause");

return 0;

}


[/code]

Explanation / Answer

#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include<conio.h>
using namespace std ;
int main ()
{
vector<string> Names;
vector<double>Hours;
vector<double>Payrate;
vector<char>Union;
vector<double>Uniondues;
double dues;
char code;
double hrs;
double grade;
string EmID;
cout<<" Work flow is a profitable practice. "<<
" Let's get these folks paid!! ";
for (int i= 0;i<3;i++)
{ cout<< " Enter the students name. ";
cin>>EmID;
Names.push_back(EmID);
cout<< "Hours worked?";
cin>>hrs;
while(hrs<0 || hrs>=60)
{(cout<< "Hours exceed Maxium Allowable work Hours. Child labor pentalities may result. P.S.. YOUR FIRED!!!! ")
;
cout<< " ";
cout<< " ";
cout<< " .. Enter Hours worked.";
cin>>hrs;}
Hours.push_back(hrs);
cout<< " Enter employee payrate. ";
cin >> grade;
while(grade<7.50 || grade>45.00)
{
(cout<< "Payrate not withing Allowable Range.");
cout<< " ";
cout<< " ";
cout<< " .. Enter Valid Payrate.";
cin>>grade;}
Payrate.push_back(grade);
cout<< "what is code?";
cin>> code;
while(code!='A' &&
      code!='a' &&
      code!='B' &&
      code!='b' &&
      code!='C' &&
      code!='c')
{
cout<<" Inputted union code is invalid. ";
cout<<" Enter valid Union Code ";
cin>>code;
}
switch (code)
{
case 'A': case 'a':
dues= 25.00;
break;
case 'B' : case 'b':
dues= 50.00;
break;
case 'C' : case 'c':
dues= 75.00;
break;
default:break;
}
Union.push_back(code);
Uniondues.push_back(dues);
}
// print names
for (int i= 0; i<3; i++)
{
cout<<Names[i]<<endl;
cout<<Hours[i]<<endl;
cout<<Uniondues[i]<<endl;
}
system ("pause");
return 0;
}