# Write a function, string getFarthestTwoCities(the2DArray of distance), which returns the farthest two cities in the entire table.

Even though you are encouraged to use repl.it, from this assignment and on, you develop your solutions in any IDE of your choice.  Please note that if you use your own IDE such as CLion or VS Code, it’s necessary to submit a fully functioning ‘makefile’, readme.md (markdown) along with your program source codes
OBJECTIVES: This assignment will help you to exercise the various fundamental C++ language constructs you’ve learned in the class.
If- statements/switch statements
Doubly nested loops
Functions
enum user-defined data type, converting the user entered string to an enum element
static 2D arrays:  for this assignment, you are NOT allowed to use char *.  Instead, use a static 2-D array of primitive char.
*** Please note that for this programming assignment, you do NOT need to create header files (*.h(pp)) yet.
Travel Distance Calculator (15 points) : Using a 2D static array, “distances[NUM_OF_CITIES] [NUM_OF_CITIES] of int”
[Setting up of distance table]
The number of cities in the distance grid is 15:
Atlanta, Boston, Chicago, Dallas, Denver, LA, Houston, Memphis, Miami, New York, Phoenix, Philadelphia, San Francisco, Seattle, Washington DC
Each square in a grid is set to the distance from the departure city in the first column to the arriving city in the header row.
Each square is referred to by a departure city name followed by an arrival city name for a 15 by 15 grid
For example, the value of the square, DISTANCES[DENVER, NEWYORK] of the distance grid below is 2617, phoenix to Dallas is 1422.
Use the distance table below (source:  https://www.mapcrow.info/united_states.html  (Links to an external site.)) in your program:
Here is the the link with the code with the prepopulated distance table (https://replit.com/@valleske/DistanceTable-1#main.cpp)
Write a program that asks a user to enter a departing city name at the first line and an arriving city name next line, then it looks up the distance table to retrieve and return the following information:
The distance of two cities and driving cost information based on the current gas price and car mileage efficiency entered by the user
The average distance from the departing city to all other cities.
You should define an enum type (or enum class)  for the city names and must use the enum enumerators (explicitly named constants) to specify a city name.
Here is a sample code for using enum type: enum_test – Replit (https://replit.com/@valleske/enumtest#main.cpp.)
You can use either C-string or string class for this part but string class would be simpler and easier.
The program should support at least the following three functions:
void copyDistanceTable (the2DArray of distance, number of cities)
This function takes two input parameters, but no return value.  It reads and copies the distance information from the globally declared constant distance table into the specified 2D array (the2DArray) parameter.  You declare the global distance table outside the main() function. Then you may use doubly nested loops to copy the values from the global table to the specified 2D array which is locally defined in the main() function.
Weather Alert!!  Due to a snowstorm in Colorado, I-70 has been closed so the distances from Denver to any cities west of Denver should be extended by 75 miles in the specified 2D array (the2DArray) parameter. Those cities are Los Angeles, San Francisco, and Seattle.
HINT:  You can copy and paste a pre-populated 2D distance table in this repl  (https://replit.com/@valleske/DistanceTable-1#main.cpp )to declare your own global distance 2D array.  You don’t need to type them in manually for yourself.  You may also use the example repl to learn how to declare a global 2D distance array variable in your program.
A sample code of declaring and using a 2D array:  Chapter 5 Static Arrays – Replit https://replit.com/@valleske/Chapter-5-Static-Arrays#main.cpp)  (search for  /* 2D array */)
2 input parameters
the2DArray of integers: n x n  2D static array of integers (n: 15 in this example).  Note that the 2D array must be a static array.  i.e. The array size is fixed and is known at the compilation time. You are not allowed to change the array size during the program runtime.  That means you can NOT use a dynamic array or an array of int pointers for this specific assignment.
the number of cities: the number of rows (15 in this example)
2. double getTravelCost (the2DArray of distance, theIndexOfDeparture, theIndexOfArrival)
The function takes three parameters: the 2D array of distances in integers, an enum value (the index of departure city),  and an enum value (the index of arrival city)
IMPORTANT!! The validity of ‘departure’ and ‘arrival’ city index parameters must be checked at the beginning of the function.  The valid range for both city indexes is [ATLANTA .. WASHINGTON_DC].  If the function receives a city index outside of the range, then it immediately returns ‘-1’.
Below is how the function should compute the travel cost:
First, it queries the distance between two cities from the 2-D Distance array parameter.
Next, it asks the user to enter the current gas price per gallon and the mileage per gallon (MPG) of the user’s vehicle
Then computes and returns the total gas cost of the travel between two cities using the information retrieved above
3. int getAverageDistance (the2DArray of distance, theIndexOfCity)
The function takes two parameters: the 2D array of distances (int), an enum value (the index of the city).  The validity of the city index parameters must be checked at the beginning of the function.  The valid range for both city indexes is [ATLANTA .. WASHINGTON_DC].  If the function receives a city index outside of the range, then it immediately returns ‘-1’.
It returns the average distance between the specified city and all other cities in the Distance table.
In your main() function, you should test all three functions with at least 3 sets of cities as follows:
Ask the user to enter the departure and arrival city names
The city name in the string class should be converted to the corresponding enumerator of your city enum type.
The user can enter case-insensitive strings for the city names.  (e.g., Boston == boston == bOsToN)
Your program should keep asking the user to enter a valid city name if the entered name is not in the set of the city names in the Distance Table.
Display the travel cost for the specified pair of cities
In addition, Get the average distance for all cities and find the city with the smallest average distance.
1. Write a function, string getClosetCity(the2DArray of distance, theIndexOfCity), which returns the closest city from the specified city.
The returned value must in the following format.
A string concatenating city name + distance
For example, for Denver city, it may return “Phoenix [942] miles”
2. Write a function, string getFarthestCity(the2DArray of distance, theIndexOfCity), which returns the farthest city from the specified city.
The returned value must in the following format.
A string concatenating city name + distance
For example, for Denver city, it may return “Boston [2,838] miles”
3. Write a function, string getClosestTwoCities(the2DArray of distance), which returns the closest two cities in the entire table.  You must write doubly nested loops to traverse the 2D table.
The returned value must in the following format.
A string concatenating city names + distance
For example, it may return “Boston/Houston [2,579] miles”  (This is an incorrect example for output sample purpose only)
4. Write a function, string getFarthestTwoCities(the2DArray of distance), which returns the farthest two cities in the entire table.  You must write doubly nested loops to traverse the 2D table.
The returned value may be in the following format.
A string concatenating city names + distance
For example, it should return “Boston/Houston [2,579] miles”  (This is an incorrect example for output sample purpose only)

Pages (550 words)
Approximate price: -

Why Work with Us

Top Quality and Well-Researched Papers

We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.

We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.

Free Unlimited Revisions

If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.

Prompt Delivery and 100% Money-Back-Guarantee

All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.

Original & Confidential

We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.

Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.

Try it now!

## Calculate the price of your order

Total price:
\$0.00

How it works?

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Our Services

No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.

## Essay Writing Service

No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.