Question: Question 01 : Write a Java program that prompts for and reads the latitude of a location on earth in the format: integerDegrees integerMinutes doubleSeconds

Question 01: Write a Java program that prompts for and reads the latitude of a location on earth in the format:

integerDegrees integerMinutes doubleSeconds characterPosition

where characterPosition is either N, n, S or s. If the input is valid your program converts the input latitude to decimal degrees where North latitudes are +ve, and South latitudes are ve.

26 13 15.272400 N 26.220909
50 11 55.024800 S -50.198618
25 44 36.97 s -25.743603
43 10 23.49 n 43.173192

:

Your program must recover from InputMismatchException.

Your program must recover from invalid latitude input.

Your program must use the following private static methods:

isValidLatitude that returns true if the five input values form a valid latitude; otherwise it returns false.

getDecimalDegrees that returns the decimal degree of the five input values.

Your program must be general and it must behave as in the sample program runs below.

:

A latitude can have values from 0 degrees to 90 degrees inclusive, i.e, 0 ? degrees ? 90

1 degree = 60 minutes, 1 minute = 60 seconds.

A minute can have values in the interval [0 . . . 60), i.e., 0 ? minutes

A second can have values in the interval [0 . . . 60), i.e., 0 ? seconds

Sample Program runs:

Question 01: Write a Java program that prompts for and reads the

latitude of a location on earth in the format: integerDegrees integerMinutes doubleSeconds

characterPosition where characterPosition is either N, n, S or s. If the

Enter the latitude: 50.0 60.0 45.0000 N Error: java.util.InputMismatchException Enter the latitude: 120 27 58.64320 S Erro Invalid latitude Enter the latitude: 30 50 20.67320 W Erro Invalid latitude Enter the latitude: 26 13 15.272400 N Decimal latitude: 26.220909

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!