Ice Cream Shop Menu Help!

DisplacedFlyer DisplacedFlyer
Last edited on
Well done on using [code][/code] tags on your first post, keep it up.

The next thing to work on is code indentation, like so.
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
int GetNum(string item)
{
  int num;
  string prompt = "Number of " + item + "you would like? ";
  cout << prompt;
  while ((!(cin >> num)) || (num < 0))
  {
    cin.clear();
    cin.ignore(256, '\n');
    cout << endl << "***Error: Invalid " << item << ". Please re-enter." <<
        endl << endl << prompt;
  }
  return num;
}

void PrintMenu()
{

  bool done = false;
  int menuChoice;
  char answer = 'N';
  cout << endl << setw(0) << "Menu" << endl;
  cout << setw(22) << "1 - Clear Order data" << endl;
  cout << setw(29) << "2 - Order Ice Cream Sundaes" << endl;
  cout << setw(27) << "3 - Order Ice Cream Cones" << endl;
  cout << setw(32) << "4 - Order Milkshakes" << endl;
  cout << setw(30) << "5 - Generate Receipt for order" << endl;
  cout << setw(36) << "6 - Exit program" << endl;

  cout << "Select ===> ";
  cin >> menuChoice;

  int sundaes = 0;
  int cones = 0;
  int shakes = 0;
  int totalSundaes = 0;
  int totalCones = 0;
  int totalShakes = 0;

  while (done == false)
  {
    switch (menuChoice)
    {
    case 1:
      cout << "Are you sure you would like to start the order over? (Y/N): ";
      cin >> answer;
      cin.ignore(256, '\n');
      answer = (toupper(answer));
      if (answer == 'Y')
      {
        done = true;
        cout << endl << "total sundaes before: " << totalSundaes;
        totalSundaes = 0;
        totalCones = 0;
        totalShakes = 0;
        cout << "You have cleared the data to start a new order. ";
        cout << endl << "total sundaes after: " << totalSundaes;
      }
      break;
    case 2:
      sundaes = GetNum("ice cream sundaes");
      totalSundaes = totalSundaes + sundaes;
      done = true;
      break;


> This doesn't keep the current count for the order.
Where's cases 3, 4, 5, and 6 in your code?
Thanks for the reply!! I actually figured it out since writing this. I spent five hours trying to figure it out, so in case anyone in the future needs help: All I did was (I think!) change the scope of the variables by removing the entire PrintMenu() function, putting it in main in a for loop(PrintMenu was in a for loop in main anyway). I thought I would have to use reference variables (???) but I guess I'm too new to be able to use them correctly.
Topic archived. No new replies allowed.