Food Menu

Deleted Comment
Last edited on
I would suggest displaying the food choices before asking what the user wants.

Place a do-while() loop from line 26 to 101

Add an integer variable called nr_of_customers or something to keep track of customers.

Add another case into the switch loop.
1
2
case 0:
break;


Devise a method to count the number of customers and print that out at the end.

Find a creative way to make the program loop again for a new day.

Also, take out the assignment of the prices in the switch-case. Make the prices a constant integer.
Last edited on
So, I should say:
Buffalo Wings (1)
Super Burger (2)
etc.....
Ok.. I'll try that. I'll get back to ya on this tomorrow....
So, I should say:
Buffalo Wings (1)
Super Burger (2)
etc.....
Ok.. I'll try that. I'll get back to ya on this tomorrow....
Deleted Comment
Last edited on
Deleted Comment
Last edited on
Deleted Comment
Last edited on
Try this:
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
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <iomanip>


using namespace std;


int main()
{
char choice='Y';

int order = 1;

int num1=0, num2=0, num3=0, num4=0, num5=0;
int num_customers;
int sentinel=0;
const double UnitPrice1= 6.95, UnitPrice2= 5.75,UnitPrice3= 7.25, UnitPrice4= 8.95, UnitPrice5= 4.95;
double AmountofSale1=0, AmountofSale2=0, AmountofSale3=0, AmountofSale4=0, AmountofSale5=0;


cout<<"___________________Menu________________\n\n"
     <<"_____(1) Buffalo_Wings		    $6.95_____\n"
     <<"_____(2) Super_Burger		    $5.75_____\n"
	 <<"_____(3) Italian_Sandwich	    $7.25_____\n"
	 <<"_____(4) Shrimp_Nuggets		    $8.95_____\n"
	 <<"_____(5) Veggie_Supreme		    $4.95_____\n";
	 

         
         
while (order != sentinel)
{
cout<<"From the list of food, what would you like:\n";
cin>>order;
switch(order)
			{
                
                case 0:
                break;
                
				case 1:
                     
                cout<<"How many Buffalo Wings would you like to order:\n";
                               cin>>num1;
                
                AmountofSale1 = UnitPrice1 * num1;
                break;
                
                
          
                 
				case 2: 
                cout<<"How many Super Burgers would you like to order:\n";
				               cin>>num2;
               
                AmountofSale2= UnitPrice2 * num2;
                break;
                
                
                case 3: 
                cout<<"How many Italian Sandwiches would you like to order:\n";
                                  cin>>num3;
                
                AmountofSale3= UnitPrice3 * num3;
                break;
                
                
                 
                case 4: 
                cout<<"How many Shrimp Nuggets would you like to order:\n";
                                cin>>num4;
                
                AmountofSale4= UnitPrice4 * num4;
                break;
                
                
                
                case 5: 
                cout<<"How many would Veggie Supremes you like to order:\n";
                                cin>>num5;
                
                AmountofSale5= UnitPrice5 * num5; 
                break;
                
                
                default: cout<<"Please choose a valid item from our list\n";
                }
                

{       

cout<<"You have ordered:\n\n";

cout<<left<<setw(15)<<"ITEM"<<right<<setw(10)<<"QUANTITY"<<right<<setw(15)<<"UNIT PRICE"<<right<<setw(20)<<"AMOUNT OF SALE\n";


cout<<"Buffalo Wings"<<setw(6)<<left<< num1 <<setw(16)<<right<< UnitPrice1 <<setw(20) <<right<< AmountofSale1<<endl;

cout<<"Super Burger:"<<setw(6)<<left<< num2 <<setw(16)<<right<< UnitPrice2 <<setw(20) <<right<< AmountofSale2<<endl<<endl;

cout<<"Italian Sandwich:"<<setw(6)<<left<< num3 <<setw(16)<<right<< UnitPrice3 <<setw(20) <<right<< AmountofSale3<<endl<<endl;

cout<<"Shrimp Nuggets:"<<setw(6)<<left<< num4 <<setw(16)<<right<< UnitPrice4 <<setw(20) <<right<< AmountofSale4<<endl<<endl;

cout<<"Veggie Supreme:"<<setw(6)<<left<< num5 <<setw(16)<<right<< UnitPrice5 <<setw(20) <<right<< AmountofSale5<<endl<<endl;
}
              }

system("PAUSE");
return 0;
}
Ok, i would like it to update the quantity every time I get something else. I would like it to say after I've ordered something like, "would you like anything else?" Then spit out "what else would you like:", then if no, "please press O to end the processing but not the program. I would like to keep track of how many times I've used it. So like I can keep track of how many customers have processed orders based on how many times when asked if they want to play again, that they've said yes.
Use += and add onto the quantity.
So would I add it like, int num1+=0
Deleted Comment
Last edited on
Deleted Comment
Last edited on
One recommendation for cleaning up your code and making it a bit easier to maintain and possibly expand in the future, turn your menu into a vector of structs (or even wrap it all up in a menu class), i.e.

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
struct menuItem{
	//this constructor will allow us to easily add items to the vector
	//It's not 100% exception safe though
	menuItem(string a, double b): itemName(a), itemCost(b) {}
	string itemName;
	double itemCost;
};


int main()
{
                int num1, order;
	vector<menuItem> myMenu;
	myMenu.push_back(menuItem("Buffalo Wings", 6.95)); //Add Buffalo Wings to the menu
	myMenu.push_back(menuItem("Super Burger", 5.75)); //Add Super burger to the menu
	myMenu.push_back(menuItem("Italian Sandwich", 7.25)); //etc for each Menu Item

	//Now to display the menu
	cout << "  Menu" << endl;
	cout.setf(ios::left); //Make fields left justified
	for(unsigned int x = 0; x < myMenu.size(); x++)
		cout << x+1 << ". "<< setw(20) << myMenu[x].itemName << "$" << myMenu[x].itemCost << endl;
	cout << endl;

	//No need for a big switch statement anymore:
	//Once you've got your order number...
                order = 2;
        //****
        //IMPORTANT NOTE
        //Vectors are 0 based.
        //Your Input is 1 based (0 to cancel out of Order code)
        //Make sure you keep that in mind when dealing with user input
        //In menu above, 1 is added to X for display
        //In the prompt below, 1 is subtracted from user input

	cout << "How many orders of " << myMenu[order-1] << " would you like?" << endl;

                //Rest of your code here:

}


There's several things you can do to keep track of your orders. One method would be to also add the AmountofSale and ordercount to the structure as well, and just keep updating those values for each order made.

A more flexible approach would be to create an order struct as well, and keep track of independant orders that way, then just generate a final report at some given time:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
struct singleOrder{
	singleOrder(unsigned int io, unsigned int ni): itemOrdered(io), numItems(ni) {}
	unsigned int itemOrdered;
	unsigned int numItems;
};

                //Create a vector to contain all the orders made
	vector<singleOrder> orderHistory;
                //Once you've prompted for the item Number and number of items, insert that order into your order history like this:
                //orderHistory.push_back(singleOrder(itemNum, numItems));

	//Quick Sample of how to generate a report
	for(unsigned int x = 0; x < myMenu.size(); x++){
		double totalSales = 0;
		unsigned int totalQuantity = 0;
		for(unsigned int y = 0; y < orderHistory.size(); y++)
			if(orderHistory[y].itemOrdered == x)
				totalQuantity += orderHistory[y].numItems;
		totalSales = totalQuantity * myMenu[x].itemCost;
		cout << setw(20) << myMenu[x].itemName << setw(5) << totalQuantity << "$" << totalSales << endl;
	}


Adding or removing items from the menu is trivial at this point. You don't have to change any of the code for inputting orders. You don't have to change any of the code for reporting. When you do want to change the coder for inputting orders, you only need to change one block of code. ditto for the reporting code.
Deleted Comment
Last edited on
Not a reply to the question you asked, but what does this mean?

while ( order!=sentinel || order==sentinel )
Topic archived. No new replies allowed.