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
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);
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started