I got the above to work but it prints it out all on one line which I can fix. I have a distance method to find the distance between to inputted zip codes

public int distance (int zip1 , int zip2) {
final double EARTH_RADIUS = 3959;
int distance;
double p1 , p2 , p3;
ZipCode z1 = findZip(zip1);
ZipCode z2 = findZip(zip2);
double lat1 = Math.toRadians((z1.getLatitude()));
double lat2 = Math.toRadians((z2.getLatitude()));
double long1 = Math.toRadians((z1.getLongitude()));
double long2 = Math.toRadians((z2.getLongitude()));
p1 = (Math.cos(lat1)) * (Math.cos(long1)) * (Math.cos(lat2)) * (Math.cos(long2));
p2 = (Math.cos(lat1)) * (Math.sin(long1)) * (Math.cos(lat2)) * (Math.sin(long2));
p3 = (Math.sin(lat1)) * (Math.sin(lat2));
distance = (int)((Math.acos(p1 + p2 + p3)) * (EARTH_RADIUS));
return distance;
}

The math is off though because if I input 49401 and 90001 the output should be 1841 miles but my output is 2229. I also need to have an if that doesn't accept null values for the entered zips (if zip1 is not on the list) and I have no idea how to do that.