Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ language with no classes Name,City,Ranking,Rating,Price Range,Number of Reviews Uma,Barcelona,1,5.0,$$$$,792 Viana,Barcelona,2,5.0,$$ - $$$,2707 Blavis,Barcelona,3,5.0,$$ - $$$,643 My Restaurant,Barcelona,4,5.0,$$ - $$$,159 Bodega Biarritz,Barcelona,5,5.0,$$ - $$$,1078 Santa

C++ language with no classes
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Name,City,Ranking,Rating,Price Range,Number of Reviews
Uma,Barcelona,1,5.0,$$$$,792
Viana,Barcelona,2,5.0,$$ - $$$,2707
Blavis,Barcelona,3,5.0,$$ - $$$,643
My Restaurant,Barcelona,4,5.0,$$ - $$$,159
Bodega Biarritz,Barcelona,5,5.0,$$ - $$$,1078
Santa Rita Experience,Barcelona,6,5.0,$$$$,329
Rudi of Pirate Cooking,Barcelona,7,5.0,$$ - $$$,110
Chaka Khan,Barcelona,8,5.0,$$ - $$$,479
Spoonik Restaurant,Barcelona,9,5.0,$$$$,408
The Box,Barcelona,10,4.5,$,834
Problem description 5.0 Today you'll be working as a Trip Advisor software engineer. You'll help a user of your application to find a place to eat in Barcelona. You'll be given a ".csv" file in the following format: Name City Ranking Rating Price Range Reviews Santa Rita Experience Barcelona $$$$ 329 Uma Barcelona $$$$ 792 Spoonik Restaurant Barcelona $$$$ 408 Viana Barcelona $$ - $$$ 2707 Chaka Khan Barcelona $$ - $$$ 479 The Box Barcelona 834 Blavis Barcelona $$ - $$$ 643 My Restaurant Barcelona 5.0 $$ - $$$ 159 Bodega Biarritz Barcelona $$ - $$$ 1078 Rudi of Pirate Cooking Barcelona $$ - $$$ $ 5.0 110 Column descriptions: Name: Name of the restaurant. A string. City: Name of the city where the restaurant is located. A string, Ranking: Rank of the restaurant in a given city (e.g. restaurant with rank 1 is considered to be the best restaurant in a city it is located). An integer number. Rating: An average rating of the restaurant. A non-integer number. Price Range: Price range of the dishes. A string. Reviews: Number of review. An integer number. This is a part of a database that you can find here. The database is stored in a CSV (comma-separated values) file. It's a file format used to store tabular data. Rows are separated with an endline symbol and individual values are separated by comma. Note, values stored cannot contain comma or endline symbol. See "flights.csv" for an example. The user is interested in restaurants sorted by (1) Ranking and (2) Name. Also, he/she wants to (3) find restaurants by a Name and (4) get the best restaurant with a given prices. Implementation The program should run in a while loop. Each iteration the program should ask to enter the menu option (1-5). Depending on the menu option the program should do the following: 1. Show all the restaurants in a database in a human readable for- mat sorted by a Name column. 2. Show all the restaurants in a database in a human readable for- mat sorted by a Ranking column. 3. Find restaurant by a Name using a binary search. 4. Read a price range then find the restaurant with the highest Ranking that has a given price range. For example, if the user inputs "$$" you should find restaurant with a name "Viana". The result will be the same if user enters "$$$". In another words, "$$ - $$$" means that restaurant has dishes with prices "$$" and "$$". Note, that it is the highest ranking restaurant with price range "$$" for city Barcelona. But it should work for other cities as well (".csv" files with a different content). 5. Exit the loop. The program should contain at least 7 functions (excluding main). 1. "read Restaurants". Given the file input stream, and empty array of restaurants, read the .csv file with restaurants and return a size of an array. 2. "print Restaurants". Given the array of restaurants and its size it shows them in a human-readable format. 3. "sort RestaurantsBy Ranking". Sorts an array of restaurants by Ranking column. 4. "sort RestaurantsByName". Sorts an array of restaurants by Name column. 5. "binary SearchName". Given an array of restaurants sorted by Name, its size and a target name find a restaurant with a given name using binary search. Return its index or -1 if it's not found. 6. "isIn PriceRange". Given the restaurant price range as a string and a target price (was entered by the user) computes whether a restaurant price range contains a target price. You can assume that a restaurant price range is "$", "$$ - $$$" or "$$$$". When a target price range is "$", "$$", "$$$" or "$$$$". 7. "find Best Restaurant WithPrice". Given the array of restaurants, its size and a target price previously entered by user, find the best restaurant (highest Ranking) with target price in its price range. Return the index of a the found restaurant or -1 if there are no restaurant with a target price. The easiest way to do it is to do a linear search in the array of restaurants sorted by Ranking. Note, you should use "isIn PriceRange" inside this function IMPORTANT: don't use cin or cout inside functions that doesn't have "read" or "print" in a name (except for main() function). Do what function is supposed to do and print results outside. Note: you can assume that your input file has no more than 100 restaurants stored, so you can create an array of restaurants with 100 elements in it and then use only as many as you read from the file

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

Optimizing Data Collection In Warzones

Authors: Aaget Aamber

1st Edition

B0CQRRFP5F, 979-8869065902

More Books

Students also viewed these Databases questions