Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Code using C Use a series of latitude and longitude data entered from the comman

ID: 3906924 • Letter: C

Question

Code using C

Use a series of latitude and longitude data entered from the command line to
calculate the TOTAL distance between 2 points. For example, assume the lat/long data is

(32.639987, -116.995167) and

(32.640870, -116.997001).

If the input from the command line is
as follows:

E.g. C:getDist 32.639987 -116.995167 32.640870 -116.997001

The output should be:

The distance between points (32.639987, -116.995167) and (32.640870, -116.997001)
is 216.57 yards.

Do not prompt the user for information. Take your input data from the command line. Since the data is entered in lat/long pairs, your program will need at least 4 numbers to calculate distance, where location 1 is the first pair, and location 2 is the second pair.

Latitude and longitude data are typically in degrees so you will need to convert each to radians. Since ? (pi) radians is equivalent to 180 degrees, to convert from degrees to radians, you can multiply the angle in degrees by ?/180. For example, 90 degrees when converted to radians is 90* ? /180 =  ? /2= 1.57096.  

Use of functions:

Your program should make liberal use of functions. At a minimum, I anticipate your program having the following functions:

double toRadians( double deg);

double distanceBetween(double lat1, double long1, double lat2, double long2);

Explanation / Answer

double toRadians( double deg) { return deg * (3.14159 / 180); } double distanceBetween(double lat1, double long1, double lat2, double long2) { return sqrt(pow(lat2-lat1, 2) + pow(long2-long1, 2)); }