The latitude, longitude and place name are used to label a map. Implement a class with latitude and longitude as decimal degrees (33.755, for example) and a place name. Provide two constructors, one has three parameters place name, latitude and longitude in decimal degrees and the other has 7 parameters: place name, latitude degrees, latitude minutes, latitude seconds, longitude degrees, longitude minutes, longitude seconds. An example statement used to create an object is:

   MapLabels label1 = new MapLabels("Atlanta, GA",33, 45, 18, -84, 23, 24, 37, 46, 45.48, -122, 25, 9.12);
The position in degrees, minutes and seconds can be converted to decimal degrees using this formula. We will learn more about the Math methods in Chapter 4.
   decimalDegress = Math.signum(degrees) * (Math.abs(degrees) + minutes/60. + seconds/3600.);
Provide a toString method that will return an XML string with the values in this format:

   <label name="Atlanta, GA" latitude="33.755" longitude="-84.39"/>
   <label name="San Francisco, CA" latitude="37.7793" longitude="-122.4192"/>

Complete the following file:

MapLabels.java

/** A map label has a place name, longitude and latitude */ public class MapLabels { private String placeName; private double latitude; private double longitude; /** Constructs a map label with place name, logitude and latitude given in decimal degrees */ public MapLabels (String name, double aLat, double aLong) { // your work here placeName = ...; latitude = ...; longitude = ...; } /** Constructs a map label with place name, logitude and latitude given in degrees, minutes, seconds */ public MapLabels (String name, int degLat, int minLat, double secLat, int degLong, int minLong, double secLong) { // your work here placeName = ...; // decimalDegress = Math.signum(degrees) * (Math.abs(degrees) + minutes/60. + seconds/3600.); latitude = ...; longitude = ...; } /** Gets the string in XML form @return the string */ public String toString() { //your work here // use \" to print a " String label = "<label name=\"" + placeName + ...; return label; } }

Use the following file:

MapLabelsTester.java

public class MapLabelsTester
{
   public static void main(String[] args)
   {
       MapLabels label1 = new MapLabels("Atlanta, GA", 33.755, -84.39);
       System.out.println(label1.toString());
       System.out.println("Expected: <label name=\"Atlanta, GA\" latitude=\"33.755\" longitude=\"-84.39\"/>");
       
       label1 = new MapLabels("Atlanta, GA", 33, 45, 18, -84, 23, 24);
       System.out.println(label1.toString());
       System.out.println("Expected: <label name=\"Atlanta, GA\" latitude=\"33.755\" longitude=\"-84.39\"/>");

       MapLabels label2 = new MapLabels("San Francisco, CA", 37.7793, -122.4192);       
       System.out.println(label2.toString());
       System.out.println("Expected: <label name=\"San Francisco, CA\" latitude=\"37.7793\" longitude=\"-122.4192\"/>");
 
       label2 = new MapLabels("San Francisco, CA", 37, 46, 45.48, -122, 25, 9.12);       
       System.out.println(label2.toString());
       System.out.println("Expected: <label name=\"San Francisco, CA\" latitude=\"37.7793\" longitude=\"-122.4192\"/>"); 
   }
}