0

I have to write a program for class that will read a datafile into a structure. The data file is a menu of food items at a fast food restaurant. Basically simulate a cash register

I created a structure menu[26] which includes the following elements
key - a,b,c,d etc.
item - hotdog, hamburger etc.
price.

My question is this. What is the best way to create the customers order.

So far I have come up with this

while ((keystroke=getch())!='=')
	{
		cin>>keystroke;
			for (int i=0;i<26;i++)
				if (keystroke=menu[i].key)
				{
					menu[i].item=order[i].item;
					menu[i].price=order[i].price;
				}//end if
	}//end while

However I know that if the customer orders more than soda for example the order will only contain one of that item.

Can anyone suggest a better approach?

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by jonsca
0

why don't you create a struct called menuitem that can store the description/price/etc of one item. Then make an array of all the menu items selected for the order. You could call up the menuitem with a unique key (1,2,3,4...} stored within the struct menuitem.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.