Question: Hello, I need help with my C++ code. The program needs to display the last values like the first screenshot (59.99'' E) but it display

Hello, I need help with my C++ code. The program needs to display the last values like the first screenshot (59.99'' E) but it display the values like this: (5.11591e-12" E))

First Screenshot how the program needs to display the values:

Hello, I need help with my C++ code. The program needs to

Code:

Angle.h

#pragma once #include #include #include

class Angle { private: int degrees; int minutes; float seconds; char direction; public:

Angle() { degrees = 0; minutes = 0; seconds = 0; direction = 'N'; } //******************************************* //Lat = 0; Lon = 1; //******************************************* Angle(double gpsVal, bool longitude) { degrees = fabs(gpsVal); minutes = ((fabs(gpsVal) - degrees) * 60); seconds = (((fabs(gpsVal) - degrees) * 60) - minutes) * 60;

direction = (!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; direction = di; }

void setDegrees(int); void setMinutes(int); void setSeconds(float s); void setDirection(char d);

int getDegrees(); int getMinutes(); float getSeconds(); char getDirection();

void print(); std::string toString();

};

testAngle.cpp

#include "Angle.h" 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) { direction = d; }

int Angle::getDegrees() { return degrees; }

int Angle::getMinutes() { return minutes; }

float Angle::getSeconds() { return seconds; }

char Angle::getDirection() { return direction; }

void Angle::print() { cout

std::string Angle::toString() { std::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; }

Screenshot of the code with the error highlighted:

display the last values like the first screenshot (59.99'' E) but it

Also, I think that I need to implement this feature to fix that error but I do not know how.

Feature:

// feature methods void print() { cout > s; return s; } };

Enter GPS-style Coordinates: Lattitude (+/- 8-96.00): 23.4 Longitude (+/- 0-180.00):45.6 Converted from GPS to DMS, 23.4. 45.6 is: 23 23' 60' N, 450 35' 59.99" E Process returned @ (@x0) execution tine : 11.581 s Press any key to continue. Enter GPS-style coordinates: Latitude: (+/- 0-90.00): 23.4 Longitude: (+/- 0-180.00): 45.6 DMS: (23 23' 60" N, 45 36' 5.11591e-12" E) Enter GPS-style coordinates: Latitude: (+/- 0-90.00)

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!