rendered paste bodypublic int distance(int zip1, int zip2){
final double EARTH_RADIUS = 3959.0;
boolean unFound = true;
int i = 0;
double lat1 = 0; double lon1 = 0; // zip code 1
double lat2 = 0; double lon2 = 0; // zip code 2
double p1 = 0; double p2 = 0;
double p3 = 0; int distance = 0;
double answer = 0;
while(unFound == false && i < zips.size()){
if(zips.get(i).getZip() == zip1){
lat1 = Math.toRadians(zips.get(i).getLatitude());
lon1 = Math.toRadians(zips.get(i).getLongitude());
}else if(zips.get(i).getZip() == zip2){
lat2 = Math.toRadians(zips.get(i).getLatitude());
lon2 = Math.toRadians(zips.get(i).getLongitude());
}
p1 = (Math.cos(lat1) * Math.cos(lon1) * Math.cos(lat2) * Math.cos(lon2));
p2 = Math.cos(lat1) * Math.sin(lon1) * Math.cos(lat2) * Math.sin(lon2);
p3 = Math.sin(lat1) * Math.sin(lat2);
answer = Math.acos(p1+p2+p3) * 3959;
//System.out.println("" + distance );
distance = (int)(answer);
}return distance;
}