Case Switch used within nesting

How do I put a a case switch within nesting?
I need 4 flavors of cake
I need 4 kinds of pie
I need to put them into a nested case switch, that will ask if you want cake else you get pie
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
#include <iostream>
using namespace std;

int main() {
  int flavor;
  cout << "What kind of cake do you want?\n";
  cout << "1 - Flavor A\n";
  cout << "2 - Flavor B\n";
  cout << "3 - Flavor C\n";
  cout << "4 - Flavor D\n";
  cin >> flavor;
  switch (flavor) {
    case 1:
      cout << "You get cake flavor A\n";
      break;
    case 2:
      cout << "You get cake flavor B\n";
      break;
    case 3:
      cout << "You get cake flavor C\n";
      break;
    case 4:
      cout << "You get cake flavor D\n";
      break;
    default:
      cout << "You didn\'t enter a proper cake flavor!\n";
      cout << "What kind of pie do you want?\n";
      cout << "1 - Flavor A\n";
      cout << "2 - Flavor B\n";
      cout << "3 - Flavor C\n";
      cout << "4 - Flavor D\n";
      cin >> flavor;
      switch (flavor) {
        case 1:
          cout << "You get pie flavor A\n";
          break;
        case 2:
          cout << "You get pie flavor B\n";
          break;
        case 3:
          cout << "You get pie flavor C\n";
          break;
        case 4:
          cout << "You get pie flavor D\n";
          break;
        default:
          cout << "I guess you don\'t get any pie either!\n";
      }
  }
}


If you enter any number other than 1-4 it'll go to the default case in the switch.
Last edited on
Topic archived. No new replies allowed.