nested switch statement

OK having trouble with my nested switch statement. Here is the first part

“Wake Tech Healthcare” wants a computer system to direct incoming phone calls. Once the call is answered, it asks the caller to do the following:

Press 1 for making an appointment
Press 2 for billing questions
Press 3 for talking to a nurse
Press any other key to talk to operator

Write a program to simulate this telephone system. The caller is presented with the instruction above and asked to enter a choice. Use a switch statement to decide and display what the telephone system will do. For example, if option 1 is chosen, display “making a new appointment”.

now the second

“Wake Tech Healthcare” wants to make their telephone system better. In addition to what you wrote for them in Program 3, please also do the following. Present the same 4 options when the program starts. If the caller chooses 2 or 3, display the same message as before. If the caller chooses 1, do not display the “Making an appointment” message. Instead, present the following options:

Press 1 for making an appointment with Dr. Green
Press 2 for making an appointment with Dr. Fox
Press 3 for making an appointment with Dr. Davis
Press any other key to talk to operator

Use a switch statement to determine and display the caller’s choice of doctor.

here is my code I have so far

#include <iostream>
using namespace std;

int main()
{
unsigned short int number, Number;
cout << " Press 1 for making an appointment " << endl;
cout << " Press 2 for billing " << endl;
cout << " Press 3 for talking to a nurse " << endl;
cout << " press any other number for an operator" << endl;
cin >> number;
switch (number)
{
case 1:
cout << " press 1 for Dr. Green" << endl;
cout << " press 2 for Dr. Fox " << endl;
cout << " press 3 for Dr. Davis " << endl;
cin >> Number; //capture the second input here, then switch on that.
switch (Number)
{
case 1:cout << "Making an appointment with Dr. Green " << endl;
break;

case 2: cout << "Making an appointment with Dr. Fox" << endl;
break;

case 3: cout << "Making an appointment with Dr. Davis" << endl;
break;
}
break;
case 2: cout << " Billing question" << endl;
break;
case 3: cout << " Talking to a nurse" << endl;
break;
default: cout << " talking to a operator" << endl;
}

}

I found this example http://www.cplusplus.com/forum/beginner/85463/
but when i copy how he did his switch mine is just ignored.

where is my error?
What's the problem?
I ran it with no problems; maybe you get a warning because you don't have a default case in your inner switch? It would be helpful if you explicitly stated your problem.
I get no errors when i run the program but when i choose 1 as my option it does not ask me to select a doctor. The program just ends.
I got it to work I think it was a formatting issue.

the code one here is all aligned to the left where mine was not.

my second switch was indented.
Glad you got it to work but that's not the issue.

Indentation is only there for human readability, nothing else.
Topic archived. No new replies allowed.