Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use c++LANGUAGE Usage Spork program finds nearby and good restaurants/businesses. Usage: spork inputSporkFile resultsFile userLocX userLocY maxDistMiles minAvgRating Requirements Summary Spork program will help

please use c++LANGUAGE

Usage

Spork program finds nearby and good restaurants/businesses.

Usage:

spork inputSporkFile resultsFile userLocX userLocY maxDistMiles minAvgRating

Requirements Summary

Spork program will help user find nearby good restaurants and business, similar to apps such as Yelp or Urbanspoon. The Spork program will read business profiles from an input Spork file, calculate the distance between the user's location and each business, determine if each business is nearby based on a user's specified maximum distance, determine if each business is good based on the user's specified minimum rating, find the nearby and good business with the highest advertising level to output that business first, and store the results in an output file.

1.Input Spork File

The input Spork file format will provide a list of businesses, in which one business profile will be specified per line, using the following format:

BusinessName X.XX Y.YY R.RR A

With the following definitions for abbreviations in the format:

BusinessName: Name of the restaurant/business. The business name will not include any whitespace characters

X.XX: Business' X location in miles using a Cartesian coordinate system

Y.YY: Business' Y location in miles using a Cartesian coordinate system

R.RR: Business' average rating for the business

A: Business' advertising level, which must be 0, 1, or 2

Each entry will be separated by one or more whitespace characters.

The program should read up to MAX_SPORK_PROFILES entries, which is defined to be 500.

All erroneous entries that do not match the required Spork file format should be silently ignored. You should also ensure your program will not crash at runtime due to issues such as these, or due to issues such as opening an empty file, or reading in an invalid file format.

2.SporkProfile Data Structure

SporkProfile is a data structure for representing Spork profiles for businesses. The typedef and struct definitions for the SporkProfile data type are:

typedef struct SporkProfile_struct {

char businessName[MAX_BUSINESSNAME_LEN];

double locX;

double locY;

double distMiles;

double avgRating;

int adLevel;

bool isNearby;

bool isGood;

} SporkProfile;

businessName is the name of the restaurant/business. locX and locY are the x and y coordinates of the business. avgRating is the average rating for the business. adLevel is a value ranging from 0 to 2 describing the business' advertising level. isNearby is used to indicate if the business is near the user's location. isGood indicates if the business is greater than or equal to the user's minimum desired rating.

For storing Spork profiles in your program, your program must use an array of SporkProfile elements, defined within main as:

SporkProfile sporkProfiles[MAX_SPORK_PROFILES];

MAX_SPORK_PROFILES is defined to be 500.

3.Searching for Businesses

The following sections discuss the various searching algorithms you should use to find business matching the user's requirements.

3.1 Calculating Distance and Searching for Nearby Businesses

Your program should search the sporkProfiles array determine the distance of each business from the user's location, storing the distance in the Spork profile's distMiles member variable. The program should also determine if each business is nearby the user and set the Spork profile isNearby member variable to true (if the business is nearby) or false (if the business is not nearby). A business is neary if the Euclidean distance between the user's location and the business location is less than or equal to the user's specified maximum distance.

The Euclidean distance is calculate as:

This functionality should be implemented in FindNearbyBusinesses() function.

3.1 Searching for Good Businesses

Your program should search the sporkProfiles array determine if each business is good based on the user's minimum required average rating. The program will set the Spork profile isGood member variable to true if the business average rating is greater than or equal to the user's minimum required average rating, and false otherwise.

This functionality should be implemented in FindGoodBusinesses() function.

3.1 Searching for Business with Highest Advertising Level

After determining is businesses are nearby and good, your program should find the business that is both nearby, good, and has the highest advertising level. If more than one good, nearby business has the highest advertising level (i.e., there's is a tie), the first business found with that advertising level should be found. When outputting the Spork results, the business with the highest advertising level will be output.

This functionality should be implemented in GetIndexMaxSponsor() function. The function will return the index of the business, if found, and -1 otherwise.

4.Spork Results File

Your program should store all business that are both nearby and good in the Spork output file. The nearby and good business with the highest advertising level, if one exists, should be output first. All other nearby and good businesses should be output in the order they are stored in the sporkProfiles array. The Spork output file should be formatted with one valid entry per line using the following format:

BusinessName R.RR D.DD

Where:

BusinessName: Name of business.

R.RR: Business' average rating with exactly two decimal digits of precision.

D.DD: Business' distance in miles from user with exactly two decimal digits of precision.

Each entry should be separated by a single tab character (\t), and each line should end with a single newline ( ).

5.Alpha Submission

A top level design is provided for this assignment that includes sources files, partially complete main function, and function stubs for all required functions. For the alpha submission, your assignment should complete the ReadSporkDataFromFile() and WriteSporkResultsToFile() functions.

For the alpha submission, the ReadSporkDataFromFile() function should initialize isNearby and isGood to true and initialize distMiles to 0.0 for all profile entries. Note: This requirement is different for the final submission.

Deliverables (main.c, sporkprofile.c, and sporkprofile.h)

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

Database Technology And Management Computers And Information Processing Systems For Business

Authors: Robert C. Goldstein

1st Edition

0471887374, 978-0471887379

More Books

Students also viewed these Databases questions

Question

Practice what you preach.

Answered: 1 week ago

Question

2. Why has the conflict escalated?

Answered: 1 week ago

Question

1. What might have led to the misinformation?

Answered: 1 week ago