import java.util.Scanner;
public class JavaApplication59 {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double north = -180, south = 180, east = -90, west = 90;
while (true){
System.out.println("Please enter the longitude:");
double lon = scan.nextDouble();
System.out.println("Please enter the latitude:");
double lat = scan.nextDouble();
if (lon > 90 || lon < -90 || lat >180 || lat < -180){
System.out.println("Incorrect Latitude or Longitude");
}
else{
if (lat > north){
north = lat;
}
if (lat < south){
south = lat;
}
if (lon > east){
east = lon;
}
if (lon < west){
west = lon;
}
}
System.out.println("Would you like to enter another location (1 for yes, 0 for no)?");
int choice = scan.nextInt();
if (choice == 0){
break;
}
}
System.out.println("Farthest North: "+north);
System.out.println("Farthest South: "+south);
System.out.println("Farthest East: "+east);
System.out.println("Farthest west: "+west);
}
}
I hope this helps!