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?