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
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...
Related questions
Question
Provide full C++ code
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images
Recommended textbooks for you
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
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 Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
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
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY