Question: // Please follow the instructions and solve it by C++. (Mac) Thank you. Constructors testAngle.cpp and Angle.h Purpose To create an angle class that can
// Please follow the instructions and solve it by C++. (Mac) Thank you.
Constructors
testAngle.cpp and Angle.h
Purpose
To create an angle class that can be used for next assignment for distance class.
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
- prompt for the user's favorite location in the GPS format, e.g. DVC, the Eiffel tower, and the Great Pyramid at Giza... etc.
- convert the two GPS angles to DMS angles,
- construct two DMS angle class instances: longitude and latitude with the location value,
- 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
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 - testAngle.cpp, Angle.h
- Validation Test run result
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
Get step-by-step solutions from verified subject matter experts
