Question
Hello, I need to check if my program follows the requirements stated below. Especially if it follows the code highlighted on the red square. Thanks.
Hello, I need to check if my program follows the requirements stated below. Especially if it follows the code highlighted on the red square. Thanks.
Requirements:
Angle.h
#pragma once #include
using namespace std;
class Angle { private: int degrees, minutes; float seconds; char direct; public:
Angle() { degrees = 0; minutes = 0; seconds = 0; direct = 'N'; } //******************************************* //Lat = 0; Lon = 1; //******************************************* Angle(float gpsVal, bool longitude) { degrees = fabs(gpsVal); minutes = ((fabs(gpsVal) - degrees) * 60); seconds = (((fabs(gpsVal) - degrees) * 60) - minutes) * 60;
direct = (!longitude) ? ((fabs(gpsVal) == gpsVal) ? 'N' : 'S') : ((fabs(gpsVal) == gpsVal) ? 'E' : 'W');
}
Angle(int d, int m, float s, char di) { degrees = d; minutes = m; seconds = s; direct = di; }
void setDegrees(int); void setMinutes(int); void setSeconds(float s); void setDirection(char d);
int getDegrees(); int getMinutes(); double getSeconds(); char getDirection();
void print(); string toString();
};
testAngle.cpp
#include "Angle.h" #include
using namespace std;
void Angle::setDegrees(int d) { degrees = d; }
void Angle::setMinutes(int m) { minutes = m; }
void Angle::setSeconds(float s) { seconds = s; }
void Angle::setDirection(char d) { direct = d; }
int Angle::getDegrees() { return degrees; }
int Angle::getMinutes() { return minutes; }
double Angle::getSeconds() { return seconds; }
char Angle::getDirection() { return direct; }
void Angle::print() { cout
string Angle::toString() { stringstream ss; ss
int main() { double lat, lon; Angle latA, lonA; cout > lat; cout > lon;
latA = Angle(lat, 0); lonA = Angle(lon, 1);
cout
// using GPS to DMS constructor cout > lat; Angle latC(lat, 0);
cout > lon; Angle lonC(lon, 1);
cout
return 0; }
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 you're 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 Sof 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 'WF8, 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 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 1219) 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 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...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 (1) (i.e. 1218'6' longitude) 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 Process returned 0 (0x0) execution tine : 11.581 s Press any key to continue. int main() { double lat, lon; Angle lata, lonA; cout > lat; cout > lon; 11 The following code are supposed change to a constructor that use GPS angle values // However to simplify this assignment, we skip that step. // It would be a good challenge to create a constructor of such, instead of using the code below. latA = convertGPS (lat, 0); lonA = convertGPS(lon, 1); cout > lat; Angle latc(lat, 0); cout > lon; Angle lonc(lon, 1); coutStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started