Java for Everyone
Screencast
Distances on Earth
Understand the Problem
Calculate by Hand
Design an Algorithm

Read first latitude    Remind user to enter degrees

Read first longitude

Read second latitude and longitude

Convert all inputs to radians (× π / 180)

arc length = acos ( sin (lat1) sin (lat2) + cos (lat1) cos (lat2)
   cos (long2 - long1) )

distance = arc length × radius of the earth

Develop Test Cases

Test Case 1

Starting point latitude 45°, longitude 30°
Ending point latitude -45°, longitude 30°

Expected distance: 1/4 of the circumference of the earth
   = 1/4 × 2 × π × 3958 ≈ 6217 miles

Test Case 2

Starting point latitude 40.759°, longitude -73.984°   Times Sq NY
Ending point latitude 37.794°, longitude -122.395°   San Francisco

Expected distance: Somewhat less than 2919 miles

Write the Program
Test the Program