Question: ASSIGNMENT 02 Constructors testAngle.cpp and Angle.h Purpose To create an angle class that can be used for next assignment for distance class. In ocean navigation,

ASSIGNMENT 02 Constructors ASSIGNMENT 02 Constructors testAngle.cpp and

testAngle.cpp and Angle.h

Purpose

To create an angle class that can be used for next assignment for distance class.

In ocean navigation, locations are measured in DMS (Degrees, Minutes and Seconds) of latitude and longitude coordinates. Thus if youre lying off the mouth of Papeete Harbor in Tahiti, your location is (17 32' 12.498" S, 149 34' 54.717" W). The Google map shows this location as (-17.5368054, -149.5818668) in GPS coordinates.

In the DMS coordinates, there are 60 minutes in a degree, and 60 seconds in a minute (a modern approach is to use decimal minutes instead.) Longitude is measured from 0 to 180 degrees, east or west from Greenwich, England, to the international dateline in the Pacific. Latitude is measured from 0 to 90 degrees, north or south from the equator to the poles. Instead of the N, S, E, or W, the GPS coordinates uses positiveegative number: positive numbers for east and north (where the population are), and negative numbers for west and south.

Implementation

  • Create a class angle that includes four member variables: an int for degrees, an int for minutes, and a float for seconds, and a char for the direction letter (N or S of equator, E, or W of Greewich). This class angle can hold DMS coordinate for either a latitude variable or a longitude variable.
  • Write a default constructor to default value as 0 0' 0" N (not utilized by main).
  • Write a four-argument constructor for the DMS coordinate.
  • Write a constructor to take in digital_degree (GPS). Option 1: a TWO-argument constructor for the (double GPS coordinate, longitude/latitude), where the GPS coordinate is a floating number, and the boolean to represent either longitude or latitude is inputed. This TWO-argument constructor shall convert the digital-degree GPS to DMS and initialize the private data of the angle class. Option 2: just write a ONE-argument constructor for GPS cordinate!
  • Write a main() program to
  1. prompt for the user's favorite location in the GPS format, e.g. DVC, the Eiffel tower, and the Great Pyramid at Giza... etc.
  2. convert the two GPS angles to DMS angles,
  3. construct two DMS angle class instances: longitude and latitude with the location value,
  4. retrieve the longitude and latitude instances' values and display on the screen. If you like to make it pretty, you can use the hex character constant \xF8, which usually prints a degree () symbol.
  • Each coordinate shall contains one latitude angle and one longitute angle in either DMS or GPS format.

Angle Coordinate Tools http://latitude.to (Links to an external site.)

GPS (Decimal Degrees) = Degrees + minutes/60 + seconds/3600 And to convert GPS to DMS coordinates, here is how:
  • The whole units of degrees will remain the same (i.e. in 121.135 longitude, start with 121.) There are many ways to split the whole number and fraction part of a number. One of the easiest method is to use modf function (Links to an external site.) of cmath header.
  • Multiply the decimal by 60 (i.e. .135 * 60 = 8.1).
  • The whole number becomes the minutes (8').
  • Take the remaining decimal and multiply by 60. (i.e. .1 * 60 = 6).
  • The resulting number becomes the seconds (6'). Seconds can remain as a decimal.
  • Take your three sets of numbers and put them together, using the symbols for degrees (), minutes (), and seconds (') (i.e. 1218'6' longitude)

Sample Test Run

___________________________________________________

Starter Kit: The Angle.h (in Github), a class declaration is provided to jump start your development.

Source file for test application:

int main() { double lat, lon; Angle latA, lonA; cout > lat; cout > lon; latA = convertGPS(lat, 0); lonA = convertGPS(lon, 1); cout > lat; Angle latC(lat, 0); cout > lon; Angle lonC(lon, 1); cout  

Submit:

  1. testAngle.cpp, Angle.h
  2. Validation Test run result

Ref: testAngle.cpp sample code is listed above.

C:\Users\tony\Downloads\\Week02\degree.exe - 0 x Enter GPS-style Coordinates: Lattitude (+/- 0-90.00): 23.4 Longitude (+/- 0-180.00):45.6 Converted from GPS to DMS, 23.4, 45.6 is: 23 23' 60'' N, 45 35' 59.99" E execution time : 11.581 s Press any key to continue. C:\Users\tony\Downloads\\Week02\degree.exe - 0 x Enter GPS-style Coordinates: Lattitude (+/- 0-90.00): 23.4 Longitude (+/- 0-180.00):45.6 Converted from GPS to DMS, 23.4, 45.6 is: 23 23' 60'' N, 45 35' 59.99" E execution time : 11.581 s Press any key to continue

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!