Structure Practice


(Malik, Page 591-592, modified)


1)      Define a struct, menuItemType, with two members: menuItem of type string (or character array, whichever you prefer), and menuPrice of type double. Place this definition in a header file called menu.h. Print out this header file, and save it to hand in with the rest of the program.



2)      Open a .cpp file, and make sure to include the header file that you created.


In your main function, declare an array of the struct menuItemType.


Write a function called getdata that reads in the data from menu.txt, and places it into the array of structures. To make this easier for youself, start with removing the spaces from the menu names. Later you can add the spaces and deal with input issues.


Write a function called showmenu that prints out the menu, using a nice format (with dollar signs, and proper columns etc.)


Test your functions by first calling getdata and then calling showmenu from the main function. Print your code, and output, and save it to hand in with the rest of the program.


1)      Use your code above to write a program to help a local restaurant automate its breakfast billing system. The program should do the following:


a.       Show the customer the menu with prices. Tell the customer how to choose which item(s) he/she wants from the menu.


b.      Allow the customer to choose more than one item (EXTRA CREDIT: multiple items of a particular type, for example: 2 muffins).


c.       Calculate and print the bill. The bill should include a 8 % sales tax. Make sure that the bill is formatted nicely. Print your code and a sample run, and hand in with your other printouts, from parts 1 and 2 above.