switch statement in while loop

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.



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
 #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<<"\t\t\t Work flow is a profitable practice.  \n"<<
	"\t\t\t Let's get these folks paid!!\n";




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

{	cout<<  " Enter the students name.\t";
 
cin>>EmID;
Names.push_back(EmID);

	

cout<< "Hours worked?";

cin>>hrs;

while
	(hrs<0 || hrs>=60)
	
	{(cout<<  "Hours exceed Maxium Allowable work Hours.  \n")
	;
cout<< "\n";
cout<< "\n";


cout<< "\n\t\t\t.. Enter Hours worked.";
cin>>hrs;}

 
	
	Hours.push_back(hrs);



cout<< " Enter employee payrate.\t";
cin >> grade;

while
	(grade<7.50 || grade>45.00)
	
	{(cout<<  "Payrate not withing Allowable Range.");
cout<< "\n";
cout<< "\n";

cout<< "\n\t\t\t.. 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.\n";
			cout<<" Enter valid Union Code\n";
			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;
closed account (jwkNwA7f)
Please don't post the question twice. You can just "bump" your topic. Don't bump unreasonably, but in your case, I think it is necessary to bump it.
Topic archived. No new replies allowed.