#include #include #include using namespace std; const double PI = 3.14159256; int main () { double azimuth; double upAngle; double distance; double groundDistance; double xDistance; double yDistance; double wasAzimuth; double wasUp; double wasDistance; double wasGround; double wasHi; double wasX; double wasY; char xDirection; char yDirection; double height; double speed; cout << "Enter previous azimuth, up-angle and distance: "; cin >> wasAzimuth >> wasUp >> wasDistance; wasAzimuth = wasAzimuth * PI / 180; wasUp = wasUp * PI / 180.0; wasGround = wasDistance * cos (wasUp); wasHi = wasDistance * sin (wasUp); cout << "Was " << wasHi; wasY = wasGround * cos (wasAzimuth); wasX = wasGround * sin (wasAzimuth); cout << "Enter the azimuth, up-angle, and distance: "; cin >> azimuth >> upAngle >> distance; azimuth = azimuth * PI / 180.0; upAngle = upAngle * PI / 180.0; groundDistance = distance * cos (upAngle); height = distance * sin(upAngle); cout << " now " << height << endl; yDistance = groundDistance * cos (azimuth); xDistance = groundDistance * sin (azimuth); wasX = xDistance - wasX; wasY = yDistance - wasY; wasHi = height - wasHi; speed = sqrt (wasX * wasX + wasY * wasY + wasHi * wasHi) * 60.0; xDistance += wasX; yDistance += wasY; height += wasHi; cout << fixed << showpoint << setprecision(2); if (xDistance < 0.0) { xDistance = -xDistance; xDirection = 'W'; } else xDirection = 'E'; if (yDistance < 0.0) { yDistance = -yDistance; yDirection = 'S'; } else yDirection = 'N'; cout << "\nPlane speed is " << speed << " mph" << endl; cout << "\nPredicted location is " << xDistance << " miles " << xDirection << ", " << yDistance << " miles " << yDirection << " at altitude " << height << " miles"<< endl; return 0; }