subject
Computers and Technology, 22.07.2021 18:20 lisnel

LAB: Parsing food data in C++ Write the code in c++
Given a text file containing the availability of food items, write a program that reads the information from the text file and outputs the available food items. The program first reads the name of the text file from the user. The program then reads the text file, stores the information into four separate arrays, and outputs the available food items in the following format: name (category) -- description
Assume the text file contains the category, name, description, and availability of at least one food item, separated by a tab character ('\t').
Hints: Use the find() function to find the index of a tab character in each row of the text file. Use the substr() function to extract texts separated by the tab characters.
Ex: If the input of the program is:
food. txt
and the contents of food. txt are:
Sandwiches Ham sandwich Classic ham sandwich Available
Sandwiches Chicken salad sandwich Chicken salad sandwich Not available
Sandwiches Cheeseburger Classic cheeseburger Not available
Salads Caesar salad Chunks of romaine heart lettuce dressed with lemon juice Available
Salads Asian salad Mixed greens with ginger dressing, sprinkled with sesame Not available
Beverages Water 16oz bottled water Available
Beverages Coca-Cola 16oz Coca-Cola Not available
Mexican food Chicken tacos Grilled chicken breast in freshly made tortillas Not available
Mexican food Beef tacos Ground beef in freshly made tortillas Available
Vegetarian Avocado sandwich Sliced avocado with fruity spread Not available
the output of the program is:
Ham sandwich (Sandwiches) -- Classic ham sandwich
Caesar salad (Salads) -- Chunks of romaine heart lettuce dressed with lemon juice
Water (Beverages) -- 16oz bottled water
Beef tacos (Mexican food) -- Ground beef in freshly made tortillas
Food. txt file
Sandwiches Ham sandwich Classic ham sandwich Available
Sandwiches Chicken salad sandwich Chicken salad sandwich Not available
Sandwiches Cheeseburger Classic cheeseburger Not available
Salads Caesar salad Chunks of romaine heart lettuce dressed with lemon juice Available
Salads Asian salad Mixed greens with ginger dressing, sprinkled with sesame Not available
Beverages Water 16oz bottled water Available
Beverages Coca-Cola 16oz Coca-Cola Not available
Mexican food Chicken tacos Grilled chicken breast in freshly made tortillas Not available
Mexican food Beef tacos Ground beef in freshly made tortillas Available
Vegetarian Avocado sandwich Sliced avocado with fruity spread Not available

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:00
Donnie does not have powerpoint. which method would be best for elana to save and share her presentation as is? a pdf a doc an rtf a ppt
Answers: 3
question
Computers and Technology, 24.06.2019 13:00
Which best describes the condition under which the unicode output is the same as plain text ?
Answers: 1
question
Computers and Technology, 24.06.2019 17:00
Following are uses of spreadsheets. for each use, choose whether the use is a business use, consumer use, or student use. family budget: sales data: recording research data for science class:
Answers: 2
question
Computers and Technology, 24.06.2019 20:20
3. write assignment statements that perform the following operations with the variables a, b, and c: a. adds 2 to a and assigns the result to b b. multiplies b times 4 and assigns the result to a c. divides a by 3.14 and assigns the result to b
Answers: 2
You know the right answer?
LAB: Parsing food data in C++ Write the code in c++
Given a text file containing the availabi...
Questions
question
Mathematics, 14.07.2019 18:30
Questions on the website: 13722363