Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program description: write in c++ Read menu item and cost data, allow the customer to select items from the menu and produce a check for
Program description: write in c++
Read menu item and cost data, allow the customer to select items from the menu and produce a check for the customer.
- You are to read a data file (menuData.txt, provided) containing menu data for a small restaurant. Create a structure to contain the information for the menu:
Menu item
Item cost
Declare the structure in a header file.
- Declare the structure for the menu data in the header file. Declare an array variable for the menu structure LOCALLY in main. Declare an array size for the menu data as 50.
- Using a function, read and store the menu data into the menu structure array. Read until end of file. Use a counter to count and track how many menu items actually read. Pass the counter in to any processing functions that loop through the structure array (do not use a global variable) and do not hard code the actual number of rows. You will need to consider that a row of data is two rows in the file, i.e., menu item and cost.
- Using a function, open the input file and an output file. If either file fails to open, display a proper message to the customer and exit the program. Request the input and output file names from the user. The output file will be used to print the check.
- Using a function, display the available menu to the user. Display an item number, the menu item name and the cost.
- Using a function, allow the user to choose items from the menu by item number and how many of that item. For example, if the user wants 2 orders of #10 Hamburger, the user would choose item 10 and two for how many. User may choose multiple items up to the number of menu items. This list should be maintained to produce the check.
- Using a function, once the user decides ordering is complete, total the bill and apply 5% tax. Display (cout) on console and write to the output file the items ordered by name, not item number, how many of the menu item ordered, the tax and the total bill for the customer. Also write this information to the output file. Monetary values must have 2 decimal places and be preceded by a dollar sign ($).
- Using a function, close all files prior to program end.
- The program need only serve one customer at a time for each execution.
- Main should contain function calls only; no processing unless evaluating the return from a function call.
- All structure DECLARATIONS, global constants and function prototypes MUST be in a header file. Include the header file in the program. DO NOT CODE THE FUNCTIONS IN THE HEADER FILE. Functions MUST be coded in the .cpp file AFTER main.
- Each function must have required documentation (pre and post conditions).
text file
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 Soft Drink 1.75 Hamburger 5.00 Cheeseburger 6.75 French Fries 2.50
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started