Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

9 . 1 1 LAB: Parsing food data Given a text file containing the availability of food items, write a program that reads the information

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

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

Intelligent Information And Database Systems 12th Asian Conference ACIIDS 2020 Phuket Thailand March 23 26 2020 Proceedings

Authors: Pawel Sitek ,Marcin Pietranik ,Marek Krotkiewicz ,Chutimet Srinilta

1st Edition

9811533792, 978-9811533792

More Books

Students also viewed these Databases questions

Question

Understand how customers respond to effective service recovery.

Answered: 1 week ago