Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Lesson_20_Activity {
- public static void main(String[] args) {
- Scanner scan= new Scanner(System.in);
- int x = 1;
- double lon = 0;
- double lat = 0;
- double maxlat = -90;
- double minlat = 90;
- double maxlon = -180;
- double minlon = 180;
- while (x == 1)
- {
- System.out.println("Please enter the latitude:");
- lat = scan.nextDouble();
- System.out.println("Please enter the longitude:");
- lon = scan.nextDouble();
- if ((lat < -90 || lat > 90) || (lon < -180 || lon > 180)) {
- System.out.println("Incorrect Latitude or Longitude");
- }
- else {
- if (lat > maxlat)
- maxlat = lat;
- if (lat < minlat)
- minlat = lat;
- if (lon > maxlon)
- maxlon = lon;
- if (lon < minlon)
- minlon = lon;
- System.out.println("Would you like to enter another location?");
- x = scan.nextInt();
- }
- }
- System.out.println("Farthest North: " + maxlat);
- System.out.println("Farthest South: " + minlat);
- System.out.println("Farthest East: " + maxlon);
- System.out.println("Farthest West: " + minlon);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement