18.11 LAB: Parsing food data 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 should first read the name of the text file from the user. The program then should read the text file, line by line. If a food is available, the program should output the available food item 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 the text separated by the tab characters. Ex: If the input of the program is: food.txt and the contents of food.txt are: Sandwiches Sandwiches Sandwiches Salads Ham sandwich Classic ham sandwich Classic cheeseburger Available Chicken salad sandwich Chicken salad sandwich Not available Cheeseburger Not available Caesar salad Chunks of romaine heart lettuce dressed with lemon juice Salads Asian salad Mixed greens with ginger dressing, sprinkled with sesame Water 16oz bottled water Beverages Beverages Coca-Cola 16oz Coca-Cola Mexican food Mexican food Vegetarian Available Not available Available Not available Chicken tacos Grilled chicken breast in freshly made tortillas Beef tacos Ground beef in freshly made tortillas Available Avocado sandwich Sliced avocado with fruity spread Not available the output of the program is: Ham sandwich (Sandwiches) Caesar salad (Salads) Water (Beverages) -- -- -- Classic ham sandwich Chunks of romaine heart lettuce dressed with lemon juice 16oz bottled water Beef tacos (Mexican food) -- Ground beef in freshly made tortillas Not available

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Provide full C++ code

18.11 LAB: Parsing food data
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 should first read the name of the text file from the user. The program then should read the text file, line
by line. If a food is available, the program should output the available food item 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 the text
separated by the tab characters.
Ex: If the input of the program is:
food.txt
and the contents of food.txt are:
Classic ham sandwich
Classic cheeseburger
Available
Chicken salad sandwich Chicken salad sandwich Not available
Cheeseburger
Sandwiches
Ham sandwich
Sandwiches
Sandwiches
Salads
Caesar salad
Not available
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
Beverages
Coca-Cola
Mexican food
Mexican food
16oz Coca-Cola
Available
Not available
Chicken tacos Grilled chicken breast in freshly made tortillas
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)
Water (Beverages)
--
--
Chunks of romaine heart lettuce dressed with lemon juice
16oz bottled water
Beef tacos (Mexican food)
--
Ground beef in freshly made tortillas
Not available
Transcribed Image Text:18.11 LAB: Parsing food data 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 should first read the name of the text file from the user. The program then should read the text file, line by line. If a food is available, the program should output the available food item 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 the text separated by the tab characters. Ex: If the input of the program is: food.txt and the contents of food.txt are: Classic ham sandwich Classic cheeseburger Available Chicken salad sandwich Chicken salad sandwich Not available Cheeseburger Sandwiches Ham sandwich Sandwiches Sandwiches Salads Caesar salad Not available 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 Beverages Coca-Cola Mexican food Mexican food 16oz Coca-Cola Available Not available Chicken tacos Grilled chicken breast in freshly made tortillas 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) Water (Beverages) -- -- Chunks of romaine heart lettuce dressed with lemon juice 16oz bottled water Beef tacos (Mexican food) -- Ground beef in freshly made tortillas Not available
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY