Question
Hello I just need a little help with my C++ program. The program should ask one time to enter the GPS-style coordinates but instead the
Hello I just need a little help with my C++ program. The program should ask one time to enter the GPS-style coordinates but instead the program ask the user again to enter the coordinates. I just need help of fixing that. Thanks.
Angle.h
//Angle.h
#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(float 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 //testAngle.cpp
#include "Angle.h" #include
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() { float 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; }
Code output:
It should display it one time like this output example:
Enter GPS-style coordinates: Latitude: (+/- 0-90.00): 23.4 Longitude: (+/- 0-180.00): 45.6 DMS: (23 23' 60.00" N, 45 35' 59.99" 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
Step 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