Я не уверен, почему я получаю вывод NaN для этого кода, я мог бы использовать некоторую помощь от вас, ребята, чтобы просмотреть его, спасибо!
package ch_4_PA;
public class PA_4_3 {
public PA_4_3() {
// TODO Auto-generated constructor stub
}
public static void main(String[] args) {
// TODO Auto-generated method stub
double xAtl = Math.toRadians(33.7489954) ;
double yAtl = Math.toRadians(-84.3879824) ;
double xOrl = Math.toRadians(28.538355) ;
double yOrl = Math.toRadians(-81.3792365) ;
double xSav = Math.toRadians(32.0835407) ;
double ySav = Math.toRadians(-81.0998342) ;
double xCha = Math.toRadians(35.2270869) ;
double yCha = Math.toRadians(-80.8431267) ;
//sets coordinates for each city
double radius = 6371.01 ;
//radius of Earth
double distanceAtltoSav = radius * Math.acos( (Math.sin(xAtl)) * (Math.sin(xSav)) + (Math.cos(xAtl)) * (Math.cos(yAtl - ySav))) ;
//calculates distance from Atl to Sav
double distanceOrltoCha = radius * Math.acos( (Math.sin(xOrl)) * (Math.sin(xCha)) + (Math.cos(xOrl)) * (Math.cos(yOrl - yCha))) ;
//Calculates distance from Orl to Cha
double area;
//triangles will be h=distance Atl to Sav / 2 and b = distance Orl to Cha
double triarea = (distanceAtltoSav / 2) * (distanceOrltoCha) * 0.5 ;
area = triarea * 2 ;
System.out.println("The area between the cities is: " + area + "km^2") ;
}
}