Question: I am stuck on this question. Write the class, GeoLocation.java . You can refer to Name.java used in the lecture to complete the below exercises.

I am stuck on this question.

Write the class, GeoLocation.java. You can refer to Name.java used in the lecture to complete the below exercises. Do the following: 1. Create two instance variables, lat and lng, both of which should be doubles. 2. Write the default constructor. 3. Write the non-default constructor. 4. Write 2 accessor methods, one for each instance variable. 5. Write 2 mutator methods, one for each instance variable. 6. Write a method that will return the location in the format "(lat, lng)" (the toString method). 7. Write a method that will return true if the latitude is between -90 and +90. 8. Write a method that will return true if the longitude is between -180 and +180. 9. Optional: Write a method that will take a String in the format "(lat, lng)" and return a GeoLocation. 10. Now write an application class that instantiates two instances of GeoLocation. One instance should use the default constructor and the other should use the non-default constructor. Display the values of the instance variables by calling the accessor methods.

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!