Selection Choices with "Switch Statements" Not Working Correctly

Hello,

I am having trouble figuring out how to set up Switch statements to display a caller's choice of Dr.'s. Most of the code works as it should, but I still can't figure out how to make the code display the Dr.'s name after a selection is made in the first Switch statement. I'm sure it's something simple I'm overlooking, so any help would be appreciated...

Here's the code:

#include<iostream>

using namespace std;

int main ()
{
int choice = 0;
int drChoice = 0;

cout << "Enter your choice [1, 2, 3]: ";
cin >> choice;

switch (choice)
{
case 1: cout << "Press 1 for making an appointment with Dr. Green." << endl;
cout << "Press 2 for making an appointment with Dr. Fox." << endl;
cout << "Press 3 for making an appointment with Dr. Davis" << endl;
cin >> choice;
break;
cout << "Press any other key to talk to an operator" << endl;

case 2: cout << "Billing questions" << endl;
break;
case 3: cout << "Talking to a nurse" << endl;
break;
default: cout << "Talking to an operator" << endl;
cin >> choice;
}

switch (drChoice)
{
case 1: cout << "Making an appointment with Dr. Green." << endl;
case 2: cout << "Making an appointment with Dr. Fox." << endl;
case 3: cout << "Making an appointment with Dr. Davis" << endl;
cin >> drChoice;
break;
cout << "Press any other key to talk to an operator" << endl;
}

system ("pause");
return 0;
}
Please use code tags...
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
#include<iostream>

using namespace std; 

int main ()
{
int choice = 0;
int drChoice = 0;

cout << "Enter your choice [1, 2, 3]: ";
cin >> choice;

switch (choice)
{
case 1: cout << "Press 1 for making an appointment with Dr. Green." << endl; 
cout << "Press 2 for making an appointment with Dr. Fox." << endl;
cout << "Press 3 for making an appointment with Dr. Davis" << endl;
cin >> choice;  // This should be drChoice
break;
cout << "Press any other key to talk to an operator" << endl; //What is this?  It's not inside any of the cases

case 2: cout << "Billing questions" << endl;
break; 
case 3: cout << "Talking to a nurse" << endl;
break;
default: cout << "Talking to an operator" << endl;
cin >> choice;  // This does nothing.
} 

switch (drChoice)
{
case 1: cout << "Making an appointment with Dr. Green." << endl;
case 2: cout << "Making an appointment with Dr. Fox." << endl;
case 3: cout << "Making an appointment with Dr. Davis" << endl;
cin >> drChoice; // Again, this does nothing
break; 
cout << "Press any other key to talk to an operator" << endl; // Again, this is outside any case choices
} 

system ("pause");
return 0;
}


Also, if you don't know how to use code tags, just put ["code"] at the start of your code and ["/code"] at the end (without the quotes).
Thank you! All is working fine now. I'm not familiar with the term "code tags" (my professor doesn't use this term), but I added some int named constants to fix the problem, so I'm assuming that's what you meant. :-)
Code tags just format your code to look like mine instead of like yours. You use them like I described above.
At first I'm thinking, "What the heck are code tags? " I'm a newbie here, but now I get it. It adds color, etc., to the C++ code...

Doh!
Topic archived. No new replies allowed.