Student needing help please in my C++ class

Pages: 12
I am having an issue with this assignment.

Write a program to help a local restaurant automate its breakfast billing system. The program should do the following:

Show the customer the different breakfast items offered by the restaurant.
Allow the customer to select more than one item from the menu.
Calculate and print the bill.
Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right of the item):

food Price
Plain Egg $1.45
Bacon and Egg $2.45
Muffin $0.99
French Toast $1.99
Fruit Basket $2.49
Cereal $0.69
Coffee $0.50
Tea $0.75
Use an array menuList of type menuItemType, as defined in Programming Exercise 3. Your program must contain at least the following functions:

Function getData: This function loads the data into the array menuList.
Function showMenu: This function shows the different items offered by the restaurant and tells the user how to select the items.
Function printCheck: This function calculates and prints the check. (Note that the billing amount should include a 5% tax.)
A sample output is:

Welcome to Johnny's Resturant
----Today's Menu----
1: Plain Egg $1.45
2: Bacon and Egg $2.45
3: Muffin $0.99
4: French Toast $1.99
5: Fruit Basket $2.49
6: Cereal $0.69
7: Coffee $0.50
8: Tea $0.75

You can make up to 8 single order selections
Do you want to make selection Y/y (Yes), N/n (No): Y

Enter item number: 1

Select another item Y/y (Yes), N/n (No): Y

Enter item number: 2

Select another item Y/y (Yes), N/n (No): N

Welcome to Johnny's Resturant
Plain Egg $1.45
Bacon and Egg $2.45
Tax $0.20
Amount Due $4.10
Format your output with two decimal places. The name of each item in the output must be left justified. You may assume that the user selects only one item of a particular type.

The main part I am havig trouble with is in this section of the coding here

( showMenu(menuList, menuItems);
while(ordering || choice == 'Y' || choice == 'y')
{
cout << "Do you want to make selection Y/y (Yes), N/n (No): " << endl;
cin >> choice;
cout << "Enter item number" << endl;
cin >> orderChoice;
do
{
if (orderChoice > 0 && orderChoice <= menuItems)
{
menuOrder[orderChoice - 1] += 1;
cout << "Select another item Y/y (Yes), N/n (No): " << endl;
cin >> choice1;
cout << "Enter item number" << endl;
cin >> orderChoice;
}
else
ordering = false;
}
while (orderChoice > 0 && orderChoice <= menuItems && choice1 == 'Y' && choice1 == 'y');

printCheck(menuList, menuOrder, menuItems);
cin.ignore(2);
return 0;
}
)
If I take out the do while the program kinda works right if I say Y/y it asks for the number if I enter a number it asks the message again. however if I say N/n or hit 0 it still prompts the next message and I have to hit 0 two times for it to go to the rest of the code. with the statement in the coding like now I get an error message saying a function is not allowed before all of my Void sections. I have been stuck for a few days and my assignment is due on Monday. Can someone please show me what I have done wrong and how to fix it.

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
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

using namespace std;
   
//struct for menuItemType
  struct menuItemType
  {
      string menuItem;
      double menuPrice;
  };
  void getData(menuItemType menuList[]);
  void showMenu(menuItemType menuList[], int x);
  void printCheck(menuItemType menuList[], int menuOrder[], int x);
   
  int main()
  {
   
      
      const int menuItems = 8;
      menuItemType menuList[menuItems];
      int menuOrder[menuItems] = {0};
      int orderChoice = 0;
      bool ordering = true;
      char choice;
      char choice1;
      
      getData(menuList);
      
      showMenu(menuList, menuItems);
      while(ordering || choice == 'Y' || choice == 'y')
      {
          cout << "Do you want to make selection Y/y (Yes), N/n (No): " << endl;
          cin >> choice;  
          cout << "Enter item number" << endl;
          cin >> orderChoice;
          do 
          {  
            if (orderChoice > 0 && orderChoice <= menuItems)
            {
              menuOrder[orderChoice - 1] += 1;
              cout <<  "Select another item Y/y (Yes), N/n (No): " << endl;
              cin >> choice1;
              cout << "Enter item number" << endl;
              cin >> orderChoice;
            }
            else
              ordering = false;
          }
          while (orderChoice > 0 && orderChoice <= menuItems && choice1 == 'Y' && choice1 == 'y');
            
        printCheck(menuList, menuOrder, menuItems);
      cin.ignore(2);
        return 0;
          }
          
          
  
   
  void getData(menuItemType menuList[])
  {
      
      menuItemType plainEgg;
      menuItemType baconEgg;
      menuItemType muffin;
      menuItemType frenchToast;
      menuItemType fruitBasket;
      menuItemType cereal;
      menuItemType coffee;
      menuItemType tea;
   
      
      plainEgg.menuItem = "Plain Egg";
      plainEgg.menuPrice = 1.45;
      baconEgg.menuItem = "Bacon and Egg";
      baconEgg.menuPrice = 2.45;
      muffin.menuItem = "Muffin";
      muffin.menuPrice = 0.99;
      frenchToast.menuItem = "French Toast";
      frenchToast.menuPrice = 1.99;
      fruitBasket.menuItem = "Fruit Basket";
      fruitBasket.menuPrice = 2.49;
      cereal.menuItem = "Cereal";
      cereal.menuPrice = 0.69;
      coffee.menuItem = "Coffee";
      coffee.menuPrice = 0.50;
      tea.menuItem = "Tea";
      tea.menuPrice = 0.75;
   
      menuList[0] = plainEgg;
      menuList[1] = baconEgg;
      menuList[2] = muffin;
      menuList[3] = frenchToast;
      menuList[4] = fruitBasket;
      menuList[5] = cereal;
      menuList[6] = coffee;
      menuList[7] = tea;
  }
   
  void showMenu(menuItemType menuList[], int x)
  {
      
      int count;
   
      cout << "Welcome to Johnny's Resturant" << endl;
      cout << "You can make up to 8 single order selections" << endl;
      for(count = 0; count < x; count++)
      {
          cout << setw(2) << left << "[" << count + 1 << "]"
               << menuList[count].menuItem << '$'
               << menuList[count].menuPrice << endl;
      }
  }
   
  void printCheck(menuItemType menuList[], int menuOrder[], int menuItems)
  {
      double checkTotal = 0;
      double checkTax = 0;
      const double TAX = .05;
      cout << "Thanks for eating at Johnny's"
           << "Customer check: " << endl;
      for(int i = 0; i < menuItems; i++)
      {
      if(menuOrder[i] > 0) {
        cout << setprecision(3) << setw(10) << left << menuList[i].menuItem
           << '$' << (menuList[i].menuPrice * menuOrder[i]) << endl;
        checkTotal += (menuList[i].menuPrice * menuOrder[i]);
      }
      }
      checkTax = checkTotal * TAX;
      checkTotal += checkTax;
      cout << setw(14) << left << "Tax" << checkTax << endl
           << setw(14) << left << "Total" << checkTotal << endl;
  }

Last edited on
@XzainKarrito,
PLEASE USE CODE TAGS (the <> formatting button to the right), when posting code!

Along with the proper indenting, it makes it easier to read your code, and thus also easier to respond to your post.

Tutorials on how to use code tags:

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/


I've found the second link to be the most help.

Hint: You can hit "edit post", highlight your code and then press the <> formatting button.
Note: This will not automatically indent your code! That part is up to you!

I've found it's easiest to copy and paste pre-indented code directly from the IDE, that way it is already properly formatted.

You can use the "preview" button at the bottom to see how it looks.
Using Code Tags, @Handy Andy, from cplusplus.com

Additionally, what errors are you getting exactly? If I know exactly what errors you're getting, it will be easier to help you.
Thanks!
max
Last edited on
the errors I get are these

main.cpp: In function ‘int main()’:
main.cpp:63:3: error: a function-definition is not allowed here before ‘{’ token
{
^
main.cpp:103:3: error: a function-definition is not allowed here before ‘{’ token
{
^
main.cpp:118:3: error: a function-definition is not allowed here before ‘{’ token
{
^
main.cpp:136:3: error: expected ‘}’ at end of input
}
^
/bin/bash: line 4: ./a.out: No such file or directory
It appears that you are missing a closing brace for main(). Remember that you can't implement a function inside another function.

If your indentation was a little more consistent you would probably be able to see the problem easier:

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
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>

using namespace std;

//struct for menuItemType
struct menuItemType
{
    string menuItem;
    double menuPrice;
};
void getData(menuItemType menuList[]);
void showMenu(menuItemType menuList[], int x);
void printCheck(menuItemType menuList[], int menuOrder[], int x);

int main()
{


    const int menuItems = 8;
    menuItemType menuList[menuItems];
    int menuOrder[menuItems] = {0};
    int orderChoice = 0;
    bool ordering = true;
    char choice;
    char choice1;
    
    getData(menuList);
    
    showMenu(menuList, menuItems);
    while(ordering || choice == 'Y' || choice == 'y')
    {
        cout << "Do you want to make selection Y/y (Yes), N/n (No): " << endl;
        cin >> choice;
        cout << "Enter item number" << endl;
        cin >> orderChoice;
        do
        {
            if(orderChoice > 0 && orderChoice <= menuItems)
            {
                menuOrder[orderChoice - 1] += 1;
                cout <<  "Select another item Y/y (Yes), N/n (No): " << endl;
                cin >> choice1;
                cout << "Enter item number" << endl;
                cin >> orderChoice;
            }
            else
                ordering = false;
        } while(orderChoice > 0 && orderChoice <= menuItems && choice1 == 'Y' && choice1 == 'y');
        
        printCheck(menuList, menuOrder, menuItems);
        cin.ignore(2);
        return 0;
    }
    
    
    
    
    void getData(menuItemType menuList[])
    {
    
        menuItemType plainEgg;
        menuItemType baconEgg;
        menuItemType muffin;
        menuItemType frenchToast;
        menuItemType fruitBasket;
        menuItemType cereal;
        menuItemType coffee;
        menuItemType tea;
        
        
        plainEgg.menuItem = "Plain Egg";
        plainEgg.menuPrice = 1.45;
        baconEgg.menuItem = "Bacon and Egg";
        baconEgg.menuPrice = 2.45;
        muffin.menuItem = "Muffin";
        muffin.menuPrice = 0.99;
        frenchToast.menuItem = "French Toast";
        frenchToast.menuPrice = 1.99;
        fruitBasket.menuItem = "Fruit Basket";
        fruitBasket.menuPrice = 2.49;
        cereal.menuItem = "Cereal";
        cereal.menuPrice = 0.69;
        coffee.menuItem = "Coffee";
        coffee.menuPrice = 0.50;
        tea.menuItem = "Tea";
        tea.menuPrice = 0.75;
        
        menuList[0] = plainEgg;
        menuList[1] = baconEgg;
        menuList[2] = muffin;
        menuList[3] = frenchToast;
        menuList[4] = fruitBasket;
        menuList[5] = cereal;
        menuList[6] = coffee;
        menuList[7] = tea;
    }
    
    void showMenu(menuItemType menuList[], int x)
    {
    
        int count;
        
        cout << "Welcome to Johnny's Resturant" << endl;
        cout << "You can make up to 8 single order selections" << endl;
        for(count = 0; count < x; count++)
        {
            cout << setw(2) << left << "[" << count + 1 << "]"
                 << menuList[count].menuItem << '$'
                 << menuList[count].menuPrice << endl;
        }
    }
    
    void printCheck(menuItemType menuList[], int menuOrder[], int menuItems)
    {
        double checkTotal = 0;
        double checkTax = 0;
        const double TAX = .05;
        cout << "Thanks for eating at Johnny's"
             << "Customer check: " << endl;
        for(int i = 0; i < menuItems; i++)
        {
            if(menuOrder[i] > 0) {
                cout << setprecision(3) << setw(10) << left << menuList[i].menuItem
                     << '$' << (menuList[i].menuPrice * menuOrder[i]) << endl;
                checkTotal += (menuList[i].menuPrice * menuOrder[i]);
            }
        }
        checkTax = checkTotal * TAX;
        checkTotal += checkTax;
        cout << setw(14) << left << "Tax" << checkTax << endl
             << setw(14) << left << "Total" << checkTotal << endl;
    }
    
@XzainKarrito,
/bin/bash: line 4: ./a.out: No such file or directory

Check to make sure you are in the correct directory.

Enter "ls" to list everything in your current dir, and if you don't see a.out listed in the directory, then you're in the wrong one.

Either that or it doesn't exist, in which case you'll have to compile it and try again. What compiler are you using?

By the way, thank you for editing your post and posting your errors! :)
Last edited on
Not sure which compiler it is. I am using MindTap by Cengage to do all the assignments and it has a compiler for the labs but I am guessing Sandbox. I have the fixed bracket but still get the same errors. I still am not sure how to use the coding to get the results I am looking for seeing as I can't use a function within another function.
Last edited on
I know that this is where in my code that I have the issue I just don't know how to fix it.


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
  showMenu(menuList, menuItems);
    while(ordering || choice == 'Y' || choice == 'y')
    {
        cout << "Do you want to make selection Y/y (Yes), N/n (No): " << endl;
        cin >> choice;
        cout << "Enter item number" << endl;
        cin >> orderChoice;
        do
        {
            if(orderChoice > 0 && orderChoice <= menuItems)
            {
                menuOrder[orderChoice - 1] += 1;
                cout <<  "Select another item Y/y (Yes), N/n (No): " << endl;
                cin >> choice1;
                cout << "Enter item number" << endl;
                cin >> orderChoice;
            }
            else
                ordering = false;
        } while(orderChoice > 0 && orderChoice <= menuItems && choice1 == 'Y' && choice1 == 'y');
        
        printCheck(menuList, menuOrder, menuItems);
        cin.ignore(2);
        return 0;
    }
    
Read https://www.cplusplus.com/forum/beginner/277979/#msg1199929 again.
jib indented it according to the braces.

Notice how the functions from line 61 are NOT in the left column.
This means your main is missing a closing brace.

So put a } on line 57.

Also, the return 0; means your outer while loop is not going to loop at all.
./a.out: No such file or directory


That happened because the program didn't compile ....

I have the fixed bracket but still get the same errors.


Can't have fixed the bracket. By the way, it is a brace not a bracket. <> are angle brackets. [] are square brackets

I still am not sure how to use the coding to get the results I am looking for seeing as I can't use a function within another function.


It is only because you had functions defined inside the main function. You are on the right track, just need to put the closing brace in the correct place - hint at the end of the main function.

Your IDE should automatically do braces for you. The old school way of doing the same thing: Type both the opening and closing brace, then go back and fill in what is inside the braces. That way you will never have a mismatching brace, parentheses or anything else that comes in pairs.

Consider using a switch statement instead of a whole of of convoluted logic to get what you want. Also, with the choice variable, convert it to uppercase to halve any logic that you have.
@XzainKarrito,
Consider using toupper() instead of this:
 
while (ordering || choice == 'Y' || choice == 'y')

You will need to #include <cctype>

It would look like:
 
while (ordering || toupper (choice) == 'Y')

Just a bit shorter code.
So I have made a lot of changes and now I get the menu but when I say no it goes through the questions again before printing the final report. Not sure what I did to get it to do it twice like that.

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
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cctype>

using namespace std;

//struct for menuItemType
struct menuItemType
{
    string menuItem;
    double menuPrice;
};

void getData(menuItemType menuList[]);
void showMenu(menuItemType menuList[], int x);
void printCheck(menuItemType menuList[], int menuOrder[], int x);

int main()
{

    const int menuItems = 8;
    menuItemType menuList[menuItems];
    int menuOrder[menuItems] = {0};
    int orderChoice = 0;
    bool ordering = true;
    char choice;
    char choice1;
    
    getData(menuList);
    
    showMenu(menuList, menuItems);
    while(ordering || toupper (choice) == 'Y')
    {
        cout << "Do you want to make selection Y/y (Yes), N/n (No): " << endl;
        cin >> choice;
        switch(choice)
        {
          case 'y':
          cout << "Enter item number" << endl;
          cin >> orderChoice;
          break;
          case 'Y':
          cout << "Enter item number" << endl;
          cin >> orderChoice;
          case 'n':
          ordering = false;
          break;
          case 'N':
          ordering = false;
          break;
        }
        
        
        if(orderChoice > 0 && orderChoice <= menuItems)
        {
            menuOrder[orderChoice - 1] += 1;
            cout <<  "Select another item Y/y (Yes), N/n (No): " << endl;
            cin >> choice1;
            switch(choice1)
            {
              case 'Y':
              cout << "Enter item number" << endl;
              cin >> orderChoice;
              menuOrder[orderChoice - 1] += 1;
              break;
              case 'y':
              cout << "Enter item number" << endl;
              cin >> orderChoice;
              menuOrder[orderChoice - 1] += 1;
              break;
              case 'N':
              ordering = false;
              break;
              case 'n':
              ordering = false;
              break;
            }
        }
        else
         ordering = false;
    }
      printCheck(menuList, menuOrder, menuItems);
      cin.ignore(2);
        return 0;    
        
    
}    
    
    
    
    void getData(menuItemType menuList[])
    {
    
        menuItemType plainEgg;
        menuItemType baconEgg;
        menuItemType muffin;
        menuItemType frenchToast;
        menuItemType fruitBasket;
        menuItemType cereal;
        menuItemType coffee;
        menuItemType tea;
        
        
        plainEgg.menuItem = "Plain Egg";
        plainEgg.menuPrice = 1.45;
        baconEgg.menuItem = "Bacon and Egg";
        baconEgg.menuPrice = 2.45;
        muffin.menuItem = "Muffin";
        muffin.menuPrice = 0.99;
        frenchToast.menuItem = "French Toast";
        frenchToast.menuPrice = 1.99;
        fruitBasket.menuItem = "Fruit Basket";
        fruitBasket.menuPrice = 2.49;
        cereal.menuItem = "Cereal";
        cereal.menuPrice = 0.69;
        coffee.menuItem = "Coffee";
        coffee.menuPrice = 0.50;
        tea.menuItem = "Tea";
        tea.menuPrice = 0.75;
        
        menuList[0] = plainEgg;
        menuList[1] = baconEgg;
        menuList[2] = muffin;
        menuList[3] = frenchToast;
        menuList[4] = fruitBasket;
        menuList[5] = cereal;
        menuList[6] = coffee;
        menuList[7] = tea;
    }
    
    void showMenu(menuItemType menuList[], int x)
    {
    
        int count;
        
        cout << "Welcome to Johnny's Resturant" << endl;
        cout << "You can make up to 8 single order selections" << endl;
        for(count = 0; count < x; count++)
        {
            cout << setw(2) << left << "[" << count + 1 << "]"
                 << menuList[count].menuItem << '$'
                 << menuList[count].menuPrice << endl;
        }
    }
    
    void printCheck(menuItemType menuList[], int menuOrder[], int menuItems)
    {
        double checkTotal = 0;
        double checkTax = 0;
        const double TAX = .05;
        cout << "Thanks for eating at Johnny's"
             << "Customer check: " << endl;
        for(int i = 0; i < menuItems; i++)
        {
            if(menuOrder[i] > 0) {
                cout << setprecision(3) << setw(10) << left << menuList[i].menuItem
                     << '$' << (menuList[i].menuPrice * menuOrder[i]) << endl;
                checkTotal += (menuList[i].menuPrice * menuOrder[i]);
            }
        }
        checkTax = checkTotal * TAX;
        checkTotal += checkTax;
        cout << setw(14) << left << "Tax" << checkTax << endl
             << setw(14) << left << "Total" << checkTotal << endl;
    }


This is what it shows:
Welcome to Johnny's Resturant
You can make up to 8 single order selections
[ 1]Plain Egg$1.45
[ 2]Bacon and Egg$2.45
[ 3]Muffin$0.99
[ 4]French Toast$1.99
[ 5]Fruit Basket$2.49
[ 6]Cereal$0.69
[ 7]Coffee$0.5
[ 8]Tea$0.75
Do you want to make selection Y/y (Yes), N/n (No):
y
Enter item number
1
Select another item Y/y (Yes), N/n (No):
y
Enter item number
2
Do you want to make selection Y/y (Yes), N/n (No):
n
Select another item Y/y (Yes), N/n (No):
n
Thanks for eating at Johnny'sCustomer check:
Plain Egg $1.45
Bacon and Egg$4.9
Tax 0.318
Total 6.67

Last edited on
Okay I fixed the last issue sort of but now it doesn't go to the next question of select another item:

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
170
171
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cctype>

using namespace std;

//struct for menuItemType
struct menuItemType
{
    string menuItem;
    double menuPrice;
};

void getData(menuItemType menuList[]);
void showMenu(menuItemType menuList[], int x);
void printCheck(menuItemType menuList[], int menuOrder[], int x);

int main()
{

    const int menuItems = 8;
    menuItemType menuList[menuItems];
    int menuOrder[menuItems] = {0};
    int orderChoice = 0;
    bool ordering = true;
    char choice;
    char choice1;
    
    getData(menuList);
    
    showMenu(menuList, menuItems);
    while(ordering || toupper (choice) == 'Y')
    {
        
        cout << "Do you want to make selection Y/y (Yes), N/n (No): " << endl;
        cin >> choice;
        switch(choice)
        {
          case 'y':
          cout << "Enter item number" << endl;
          cin >> orderChoice;
          menuOrder[orderChoice - 1] += 1;
          break;
          case 'Y':
          cout << "Enter item number" << endl;
          cin >> orderChoice;
          menuOrder[orderChoice - 1] += 1;
          case 'n':
          ordering = false;
          break;
          case 'N':
          ordering = false;
          break;
        }
        
        
        if(orderChoice > 0 && orderChoice <= menuItems  && toupper (choice) == 'y')
        {
            menuOrder[orderChoice - 1] += 1;
            cout <<  "Select another item Y/y (Yes), N/n (No): " << endl;
            cin >> choice1;
            switch(choice1)
            {
              case 'Y':
              cout << "Enter item number" << endl;
              cin >> orderChoice;
              menuOrder[orderChoice - 1] += 1;
              break;
              case 'y':
              cout << "Enter item number" << endl;
              cin >> orderChoice;
              menuOrder[orderChoice - 1] += 1;
              break;
              case 'N':
              ordering = false;
              break;
              case 'n':
              ordering = false;
              break;
            }
        }
        else
         ordering = false;
    }
      printCheck(menuList, menuOrder, menuItems);
      cin.ignore(2);
        return 0;    
        
    
}    
    
    
    
    void getData(menuItemType menuList[])
    {
    
        menuItemType plainEgg;
        menuItemType baconEgg;
        menuItemType muffin;
        menuItemType frenchToast;
        menuItemType fruitBasket;
        menuItemType cereal;
        menuItemType coffee;
        menuItemType tea;
        
        
        plainEgg.menuItem = "Plain Egg";
        plainEgg.menuPrice = 1.45;
        baconEgg.menuItem = "Bacon and Egg";
        baconEgg.menuPrice = 2.45;
        muffin.menuItem = "Muffin";
        muffin.menuPrice = 0.99;
        frenchToast.menuItem = "French Toast";
        frenchToast.menuPrice = 1.99;
        fruitBasket.menuItem = "Fruit Basket";
        fruitBasket.menuPrice = 2.49;
        cereal.menuItem = "Cereal";
        cereal.menuPrice = 0.69;
        coffee.menuItem = "Coffee";
        coffee.menuPrice = 0.50;
        tea.menuItem = "Tea";
        tea.menuPrice = 0.75;
        
        menuList[0] = plainEgg;
        menuList[1] = baconEgg;
        menuList[2] = muffin;
        menuList[3] = frenchToast;
        menuList[4] = fruitBasket;
        menuList[5] = cereal;
        menuList[6] = coffee;
        menuList[7] = tea;
    }
    
    void showMenu(menuItemType menuList[], int x)
    {
    
        int count;
        
        cout << "Welcome to Johnny's Resturant" << endl;
        cout << "You can make up to 8 single order selections" << endl;
        for(count = 0; count < x; count++)
        {
            cout << setw(2) << left << "[" << count + 1 << "]"
                 << menuList[count].menuItem << '$'
                 << menuList[count].menuPrice << endl;
        }
    }
    
    void printCheck(menuItemType menuList[], int menuOrder[], int menuItems)
    {
        double checkTotal = 0;
        double checkTax = 0;
        const double TAX = .05;
        cout << "Thanks for eating at Johnny's"
             << "Customer check: " << endl;
        for(int i = 0; i < menuItems; i++)
        {
            if(menuOrder[i] > 0) {
                cout << setprecision(3) << setw(10) << left << menuList[i].menuItem
                     << '$' << (menuList[i].menuPrice * menuOrder[i]) << endl;
                checkTotal += (menuList[i].menuPrice * menuOrder[i]);
            }
        }
        checkTax = checkTotal * TAX;
        checkTotal += checkTax;
        cout << setw(14) << left << "Tax" << checkTax << endl
             << setw(14) << left << "Total" << checkTotal << endl;
    }


This is what it shows:

Welcome to Johnny's Resturant
You can make up to 8 single order selections
[ 1]Plain Egg$1.45
[ 2]Bacon and Egg$2.45
[ 3]Muffin$0.99
[ 4]French Toast$1.99
[ 5]Fruit Basket$2.49
[ 6]Cereal$0.69
[ 7]Coffee$0.5
[ 8]Tea$0.75
Do you want to make selection Y/y (Yes), N/n (No):
y
Enter item number
1
Do you want to make selection Y/y (Yes), N/n (No):
y
Enter item number
2
Do you want to make selection Y/y (Yes), N/n (No):
n
Thanks for eating at Johnny'sCustomer check:
Plain Egg $1.45
Bacon and Egg$2.45
Tax 0.195
Total 4.1
Here is my "standard school assignment reply"
Why are you NOT asking your counselor / teacher to help you ?

A code without ANY comments should be only done when your job security would be "jeopardized."

Most IDE , not compilers / linkers , let you "beautify" your code AKA ":fix" indentation and SOMETIME it will show the mismatched "brackets".

And yes, sometime the errors are not what you expect - but originally missing closing brackets in main
still pointed to source of the problem.

Analyzing errors gets easier with experience - in your initial problem your IDE MAY have the "feature" to identify bracketed blocks of code - ask your teacher.

As far as code not doing expected - learn how to set breakpoints and step thru you code till you find the issue.

Primarily my teacher hasn't talked to any of us this whole semester due to it being an online only distance class all the assignments are on Mindtap Cengage. I have asked a tutor for help and they helped me get to the point I was at when I started this post. I am completely new to C++ and am trying to learn. So I came on here hoping to find knowledgeable people to help me learn what I am messing up and not give me the answer without an explanation. The people that have posted so far have helped me learn some things I didn't know and the "Bracket was there originally I accidentally deleted it when I was trying to figure out what I was messing up before finding my area that I was having a problem at. I have set breakpoints I just don't see what I am doing wrong and am seeking advice and help as to what errors I am making, why it is doing what it is doing, and how I could go about fixing it. Thank you for your response though.
> if(orderChoice > 0 && orderChoice <= menuItems && toupper (choice) == 'y')
Your toupper is comparing with a lowercase.

You can simplify your cases like this.
1
2
3
4
5
6
7
8
9
10
11
12
    switch (choice) {
    case 'y':
    case 'Y':
      cout << "Enter item number" << endl;
      cin >> orderChoice;
      menuOrder[orderChoice - 1] += 1;
      break;
    case 'n':
    case 'N':
      ordering = false;
      break;
    }
I am completely new to C++ and am trying to learn.

There are two online tutorials you might want to look at.

1. The tutorial here at CPlusPlus. It is outdated, no C++14 or later.
http://www.cplusplus.com/doc/tutorial/

2. Learn C++. It is getting updated frequently.
https://www.learncpp.com/
Here's a version of what you have so far with a few things changed:
1. Most of what you have is fairly good but is clearer just by using some meaningful names for things.
2. I've indicated the main program changes and see if it suits what you are trying to do. There was a lot of duplication and unnecessary stuff.
3. You need to revisit the getData function. All you have is an array of structs without all those lines and variable names. Just populate the array as you would if the items were ints.
4. Of course, I haven't verified this as much as you will need to do. It looks to me though like it works.

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
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cctype>

using namespace std;

// struct for menu item
struct Item
{
    string name;
    double price;
};

void getData(Item[], int);
void showMenu(Item[], int );
void printCheck(Item[], int[], int);

int main()
{

    const int NO_ITEMS = 8;
    Item menu[NO_ITEMS];
    int order[NO_ITEMS] = {0};
    int orderChoice = 0;
    bool ordering = true;
    char choice{'Y'}; // <--

    getData(menu, NO_ITEMS);

    showMenu(menu, NO_ITEMS);
    while( ordering ) // <--
    {
        cout << "Do you want to make selection Y/y (Yes), N/n (No): " << endl;
        cin >> choice;

        switch(toupper(choice)) // <--
        {
            case 'Y':
                cout << "Enter item number" << endl;
                cin >> orderChoice;
                order[orderChoice - 1] = 1; // <-- // EDIT was off by one
                break;
            case 'N':
                ordering = false;
                break;

            default:
                cout << "Wrong answer\n";
        }
    } // <--

    printCheck(menu, order, NO_ITEMS);

    return 0;
}



void getData(Item menuList[], int no_items )
{
    // A HORRIBLY HARD WAY TO DO THIS :[
    Item plainEgg;
    Item baconEgg;
    Item muffin;
    Item frenchToast;
    Item fruitBasket;
    Item cereal;
    Item coffee;
    Item tea;


    plainEgg.name = "Plain Egg";
    plainEgg.price = 1.45;
    baconEgg.name = "Bacon and Egg";
    baconEgg.price = 2.45;
    muffin.name = "Muffin";
    muffin.price = 0.99;
    frenchToast.name = "French Toast";
    frenchToast.price = 1.99;
    fruitBasket.name = "Fruit Basket";
    fruitBasket.price = 2.49;
    cereal.name = "Cereal";
    cereal.price = 0.69;
    coffee.name = "Coffee";
    coffee.price = 0.50;
    tea.name = "Tea";
    tea.price = 0.75;

    menuList[0] = plainEgg;
    menuList[1] = baconEgg;
    menuList[2] = muffin;
    menuList[3] = frenchToast;
    menuList[4] = fruitBasket;
    menuList[5] = cereal;
    menuList[6] = coffee;
    menuList[7] = tea;
}

void showMenu(Item menuList[], int x)
{

    int count;

    cout << "Welcome to Johnny's Resturant" << endl;
    cout << "You can make up to 8 single order selections" << endl;
    for(count = 0; count < x; count++)
    {
        cout << setw(2) << left << "[" << count + 1 << "]"
        << menuList[count].name << '$'
        << menuList[count].price << endl;
    }
}

void printCheck(Item menuList[], int menuOrder[], int menuItems)
{
    double checkTotal = 0;
    double checkTax = 0;
    const double TAX = .05;
    cout << "Thanks for eating at Johnny's"
    << "Customer check: " << endl;
    for(int i = 0; i < menuItems; i++)
    {
        if(menuOrder[i] > 0) {
            cout << setprecision(3) << setw(10) << left << menuList[i].name
            << '$' << (menuList[i].price * menuOrder[i]) << endl;
            checkTotal += (menuList[i].price * menuOrder[i]);
        }
    }
    checkTax = checkTotal * TAX;
    checkTotal += checkTax;
    cout << setw(14) << left << "Tax" << checkTax << endl
    << setw(14) << left << "Total" << checkTotal << endl;
}


Welcome to Johnny's Resturant
You can make up to 8 single order selections
[ 1]Plain Egg$1.45
[ 2]Bacon and Egg$2.45
[ 3]Muffin$0.99
[ 4]French Toast$1.99
[ 5]Fruit Basket$2.49
[ 6]Cereal$0.69
[ 7]Coffee$0.5
[ 8]Tea$0.75
Do you want to make selection Y/y (Yes), N/n (No): 
y
Enter item number
1
Do you want to make selection Y/y (Yes), N/n (No): 
y
Enter item number
2
Do you want to make selection Y/y (Yes), N/n (No): 
y
Enter item number
3
Do you want to make selection Y/y (Yes), N/n (No): 
n
Thanks for eating at Johnny'sCustomer check: 
Bacon and Egg$2.45
Muffin    $0.99
French Toast$1.99
Tax           0.272
Total         5.7
Program ended with exit code: 0

Last edited on
One could have a switch with the cases being of type char, with 1 to 8, and a 'q' to quit. That way one doesn't have to ask Yes / No each time. The 'q' option works the same way as the 'N' option at the moment.

A better way to do the Items, perhaps what againtry was hinting at:

Provide a constructor for the Item struct, that sets both name and price values;
Make MenuList a std::vector instead of an array, use emplace_back to construct each MenuItem in place.
And to demonstrate those two possibilities:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
vector<Item> vec_item
    {
        {"Plain Egg", 1.45},
        {"Bacon and Egg", 2.45},
        {"Muffin", 0.99},
        {"French Toast", 1.99},
        {"Fruit Basket", 2.49},
        {"Cereal", 0.69},
        {"Coffee", 0.50},
        {"Tea", 0.75}
    };

    for( auto i: vec_item)
    {
        cout << i.name << ' ' << i.price << '\n';
    }


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

    Item list[] =
    {
        {"Plain Egg", 1.45},
        {"Bacon and Egg", 2.45},
        {"Muffin", 0.99},
        {"French Toast", 1.99},
        {"Fruit Basket", 2.49},
        {"Cereal", 0.69},
        {"Coffee", 0.50},
        {"Tea", 0.75}
    };

    for(int i = 0; i < no_items; i++)
    {
        menu[i] = list[i];
    }
    return;


PS the vector requires a few changes to how the struct/constructor works.
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
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

// struct for menu item
struct Item
{
    string name;
    double price;
};

void getData(Item[], int);
void showMenu(Item[], int );
void printCheck(Item[], int[], int);

int main()
{
    const int NO_ITEMS = 8;
    Item menu[NO_ITEMS];
    int order[NO_ITEMS] = {0};
    int choice{0};

    getData(menu, NO_ITEMS);

    showMenu(menu, NO_ITEMS);
    while(
          cout << "Enter selection 1-8 any alpha for the Bill " &&
          cin >> choice &&
          choice != 0
          )
    {
        switch( choice )
        {
            case 1 ... 8:
                order[choice - 1] = 1;
                break;

            default:
                cout << "Wrong answer\n";
                break;
        }
    }

    printCheck(menu, order, NO_ITEMS);

    return 0;
}

void getData(Item menu[], int no_items )
{

    Item list[] =
    {
        {"Plain Egg", 1.45},
        {"Bacon and Egg", 2.45},
        {"Muffin", 0.99},
        {"French Toast", 1.99},
        {"Fruit Basket", 2.49},
        {"Cereal", 0.69},
        {"Coffee", 0.50},
        {"Tea", 0.75}
    };

    for(int i = 0; i < no_items; i++)
    {
        menu[i] = list[i];
    }
    return;
}

void showMenu(Item menuList[], int x)
{
    int count;

    cout << "       Welcome to Johnny's Resturant\n";
    cout << "You can make up to 8 single order selections\n\n";
    for(count = 0; count < x; count++)
    {
        cout
        << setw(11) << "[" << count + 1 << "] "
        << setw(14)<< menuList[count].name
        << fixed << setprecision(2)<< " $" << menuList[count].price << '\n';
    }
    cout << '\n';
}

void printCheck(Item menuList[], int menuOrder[], int menuItems)
{
    double checkTotal = 0;
    double checkTax = 0;
    const double TAX = .05;
    cout
    << "Thanks for eating at Johnny's\n"
    << "Customer check: " << endl;
    for(int i = 0; i < menuItems; i++)
    {
        if(menuOrder[i] > 0)
        {
            cout
            << setprecision(3) << setw(10) << left << menuList[i].name
            << '$' << (menuList[i].price * menuOrder[i]) << endl;
            checkTotal += (menuList[i].price * menuOrder[i]);
        }
    }
    checkTax = checkTotal * TAX;
    checkTotal += checkTax;
    cout << setw(14) << left << "Tax" << checkTax << endl
    << setw(14) << left << "Total" << checkTotal << endl;
}


       Welcome to Johnny's Resturant
You can make up to 8 single order selections

          [1]      Plain Egg $1.45
          [2]  Bacon and Egg $2.45
          [3]         Muffin $0.99
          [4]   French Toast $1.99
          [5]   Fruit Basket $2.49
          [6]         Cereal $0.69
          [7]         Coffee $0.50
          [8]            Tea $0.75

Enter selection 1-8 any alpha for the Bill 2
Enter selection 1-8 any alpha for the Bill 3
Enter selection 1-8 any alpha for the Bill y
Thanks for eating at Johnny's
Customer check: 
Bacon and Egg$2.450
Muffin    $0.990
Tax           0.172
Total         3.612
Program ended with exit code: 0
Pages: 12