Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- /**
- * Write a description of class Project5 here.
- * Kailey McNeal
- * 10-2-14
- * Project #5
- */
- public class Project5
- {
- public static void main (String[] args)
- {
- Scanner console=new Scanner (System.in);
- System.out.print("What is the latitude of the 1st city? ");
- double lat1=console.nextDouble();
- System.out.print("What is the longitude of the 1st city? ");
- double longi1=console.nextDouble();
- System.out.print("What is the latitude of the 2nd city? ");
- double lat2=console.nextDouble();
- System.out.print("What is the longitude of the 2nd city? ");
- double longi2=console.nextDouble();
- longi1=Math.toRadians(longi1);
- lat1=Math.toRadians(lat1);
- longi2=Math.toRadians(longi2);
- lat2=Math.toRadians(lat2);
- double longdis=Math.max(longi1, longi2)-Math.min(longi1, longi2); //longitudinal distance
- double angdiff=Math.acos(Math.sin(lat1)*Math.sin(lat2)+Math.cos(lat1)*Math.cos(lat2)*Math.cos(longdis)); //angular difference
- double answer=angdiff*6372.795;
- System.out.println(answer + "km");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement