Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Create a stmct Menultem containing fields for name {a string] and price {a double] of a menu item for a diner. Create a Readlten}

image text in transcribed
1. Create a stmct Menultem containing fields for name {a string] and price {a double] of a menu item for a diner. Create a Readlten} function that takes an i stream and a Menultem [both by reference} and prompts the user for the fields of the Menultem, loading the 1values into the struct's elds. Create a PrintItem function that takes an output stream {by reference] and a Menultem {by WIDE} and prints the Menultem elds to the stream in a reasonable onewline format. Create a main[} that declares a Menultem struct locally, calls Readltem, then calls Printltem. Test with a few different items. [20 points] 2. Make another program modied to include an array of ID Menultem structs. Modify Readltem to not prompt for, but instead just read the data for a struct fieldvbyufteld, and call it once for each Menultem. Then call Printltem for each stmct, numbering the items to create a menu {see below). Use files, opened and closed in main[}, for all input and output. Create a test file with the it] items and prices, and test with it. Send me the test le and the output file. (30 points] Hints: Ifyou use an i stream a for an input stream parameter, you may pass either cin or an input file handle to a function. Similarly, if you use an oatraam & for an output stream parameter, you may pass in either coat or an output file handle to the function. The only restriction is that you may only use operations that would work on aim or can: in 'lt: function. For example, you may not open [1 or close l 1 inside the function. You may use either C~strings or C++ string objects for the menu item names. You must allow for multivword item names like "bacon cheeseburger" not just "cheeseburger\". Thus, the lines in your data file will look like this {with 2 lines per entry): bacon cheeseburger 1'99 ham and cheese 4.99 etc. To read a C-string containing white space characters, use in. getlinat data, m, ' "tn' 1:.- where in is either cin oran input file handle [ora parameter ofiatream E: type), data is an array of char at least MAK+1 in length, HA): is the maximum number of characters to read 'om the input stream, and ' 'tn ' is the character at which to stop reading. To read a C++ string object containing white space characters, use garlinat in, data I: where in is either cin or an input file handle [or a parameter ofiatreern E: type) and data is a C++ string object. Here, you don't have to worry about the maximum length of the string being read. [in Windows, after extracting a number, you will need to call in . ignore {1| ; to get rid of the newline before you try another gatl ina {1| . Do this inside the RaactItam {1| function before it returns {Readltem will leave the input stream ready for the next read]. Print I tam I: 1 should not end the line itself. You might not need to do this on Mac or Linux systems. To number the items in the second exercise, print the number before calling PrintItam I: Ju

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Formation of forward bloc by subha bose was .....?

Answered: 1 week ago

Question

The S.I. unit of change is........?

Answered: 1 week ago

Question

At the generating station power is..........?

Answered: 1 week ago

Question

The maximum number of electrons in a shell can be?

Answered: 1 week ago