用java编程实现求最大圆的距离源码答案
package nameyu;import java.util.Scanner;public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner input=new Scanner(System.in); System.out.print("Enter point 1(latitude and longitude) in degress "); String s1=input.nextLine(); System.out.print("Enter point 2(latitude and longitude) in degress "); String s2=input.nextLine(); double x1=Double.parseDouble(s1.split(",")); //因为运行实例是用逗号隔开,所以这里也用逗号吧,这个split课本中可能漏讲了,自己补充吧 double y1=Double.parseDouble(s1.split(",")); double x2=Double.parseDouble(s2.split(",")); double y2=Double.parseDouble(s2.split(",")); final double r=6371.01; double result=r*Math.acos(Math.sin(Math.toRadians(x1))*Math.sin(Math.toRadians(x2))+Math.cos(Math.toRadians(x1))*Math.cos(Math.toRadians(x2))*Math.cos(Math.toRadians(y1-y2))); System.out.println("The distance between the two points is "+result+"km"); } }
页:
[1]