Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribed

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:

image text in transcribed

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): 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 27th International Conference Dasfaa 2022 Virtual Event April 11 14 2022 Proceedings Part 2 Lncs 13246

Authors: Arnab Bhattacharya ,Janice Lee Mong Li ,Divyakant Agrawal ,P. Krishna Reddy ,Mukesh Mohania ,Anirban Mondal ,Vikram Goyal ,Rage Uday Kiran

1st Edition

3031001257, 978-3031001253

More Books

Students also viewed these Databases questions

Question

=+42-1 Describe our ability to communicate nonverbally.

Answered: 1 week ago