Skip to content

Commit

Permalink
feat(3.4.3): Finished U3_L4_Activity_Three
Browse files Browse the repository at this point in the history
  • Loading branch information
101zh committed Oct 13, 2023
1 parent 4cf70b4 commit e4ea74c
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/main/java/Unit3/U3_L4_Activity_Three.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package Unit3;

import java.util.Scanner;

public class U3_L4_Activity_Three {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);

System.out.println("Please enter the latitude:");
double latitude = scanner.nextDouble();
System.out.println("Please enter the longitude:");
double longitude = scanner.nextDouble();

boolean isLatitudeWithinBounds = (latitude >= -90.0 && latitude <= 90.0);
boolean isLongitudeWithinBounds = (longitude >= -180.0 && longitude <= 180.0);

if (!isLatitudeWithinBounds) {
System.out.println("latitude is incorrect");
}
if (!isLongitudeWithinBounds) {
System.out.println("longitude is incorrect");
}
if (isLatitudeWithinBounds && isLongitudeWithinBounds) {
System.out.println("The location: " + latitude + ", " + longitude);
}

scanner.close();
}
}

0 comments on commit e4ea74c

Please sign in to comment.