Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

write in c++, using structures Program description: Read menu item and cost data, allow the customer to select items from the menu and produce a

write in c++, using structures

Program description:

Read menu item and cost data, allow the customer to select items from the menu and produce a check for the customer.

  1. 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.

  1. 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.

  1. 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.

  1. 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.

  1. Using a function, display the available menu to the user. Display an item number, the menu item name and the cost.

  1. 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.

  1. 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 ($).

  1. Using a function, close all files prior to program end.

  1. The program need only serve one customer at a time for each execution.

  1. Main should contain function calls only; no processing unless evaluating the return from a function call.

  1. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Joline Morrison, Mike Morrison

2nd Edition

? 061906448X, 978-0619064488

More Books

Students also viewed these Databases questions

Question

2. Explain grades or test results.

Answered: 1 week ago