Question: write a c++ program that calculates the distance between two geographic points. 2. Your program will have the following functions a. A header function that

write a c++ program that calculates the distance between two geographic points.

2. Your program will have the following functions

a. A header function that takes no parameters and returns nothing that displays a header. The header will print a summary explaining the purpose of the program.

b. A get_location function that takes no parameters, asks the user for a latitude and longitude and returns a tuple or list with the latitude and longitude. Make sure you tell the user what units to enter their information in!

c. A calcDistance function that takes two tuples or lists, each with a latitude and longitude, calculates the distance between those two geographic points and returns the distance.

d. The haversine formula is:

Given:

Latitude in decimal degrees: Lat1 and Lat2

Longitude in decimal degrees: Lon1 and Lon2

Radius of earth R (mean radius = 6,371km);

The distance D between points (Lat1, Lon2) and (Lat2, Lon2) can be calculated using:

A = sin((Lat2-Lat1)/2) + cos Lat1 cos Lat2 sin((Lon2-Lon1)/2)

C = 2 atan2( A, (1A) )

D = R C

3. In the main part of the program (after declaring your functions):

a. Call the Header function that displays a header.

b. Program should allow the user to do multiple calculations. Use a do another? loop.

c. Inside the loop the program will do the following:

i. Call the get_location function to get the first location.

ii. Call the get_location function again to get the second location.

iii. Call the distance function passing in the two locations above as arguments.

iv. Display a nicely formatted message to the user telling them the distance between those two locations.

v. Finally ask the user if they want to do another.

4. When done display a good bye message outside the loop

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!