Answer to Question #156214 in C++ for GELO

Question #156214

In from of C++ classes and object, one of the company which is Company ABC, an airline company is closely monitoring the distance between airplanes as they take-off on the same airport. You are asked to create a system that would calculate the distance between two planes A and B given the following plane attributes: Take-off Time, Speed (mi/hr), direction (north, east, west, south). Also, given the time where the navigation officer would like to check the distance.




1
Expert's answer
2021-01-19T15:04:56-0500
#include <iostream>
#include <cmath>
using namespace std;


class AirCompany {
    public : 
        int take_off_time1;
        int speed1;
        string direction1;
        int time_check_distance1;
        int take_off_time2;
        int speed2;
        string direction2;
        int time_check_distance2;
        float distance;
        
        void getParametrs() {
            cout << "\nEnter the first plane information: \n";
            cout << "Enter take off time the 1-plane[min]: "; cin >> take_off_time1;
            cout << "Enter the speed of 1-plane [mil/hour]: "; cin >> speed1;
            cout << "Enter the direction[north, south, east, west]: "; cin >> direction1;
            cout << "Enter time where the navigation officer would like to check the distance[min]: "; cin >> time_check_distance1;
            cout << "\nEnter the second plane information: \n";
            cout << "Enter take off time the 2-plane[min]: "; cin >> take_off_time2;
            cout << "Enter the speed of 2-plane [mil/hour]: "; cin >> speed2;
            cout << "Enter the direction[north, south, east, west]: "; cin >> direction2;
            cout << "Enter time where the navigation officer would like to check the distance[min]: "; cin >> time_check_distance2;
        }
        
        void distanceBetweenTwoPlanes () {
            if (direction1 == "north" && direction2 == "north" || direction1 == "south" && direction2 == "south" || direction1 == "east" && direction2 == "east" || direction1 == "west" && direction2 == "west") {
                distance = fabs((float)(time_check_distance1 - take_off_time1) * speed1 / 60.0 - (float)(time_check_distance2 - take_off_time2) * speed2 / 60.0);
            }
            if ((direction1 == "north" && direction2 == "south" || direction1 == "east" && direction2 == "west") || (direction1 == "south" && direction2 == "north" || direction1 == "west" && direction2 == "east")) {
                distance = fabs((float)(time_check_distance1 - take_off_time1) * speed1 / 60.0 + (float)(time_check_distance2 - take_off_time2) * speed2 / 60.0);
            }
            if ((direction1 == "north" && direction2 == "east" || direction1 == "north" && direction2 == "west") || (direction1 == "south" && direction2 == "east" || direction1 == "south" && direction2 == "west") || (direction1 == "east" && direction2 == "north" || direction1 == "east" && direction2 == "south") || (direction1 == "west" && direction2 == "north" || direction1 == "west" && direction2 == "south")) {
                distance = sqrt(pow((float)(time_check_distance1 - take_off_time1) * speed1 / 60.0, 2) + pow((float)(time_check_distance2 - take_off_time2) * speed2 / 60.0, 2));
            }
            cout << "The distance between two planes is: " << distance << " mil.";
        }
};
int main () {
    AirCompany flight;
    flight.getParametrs();
    flight.distanceBetweenTwoPlanes();
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment