In form of C++ class and objects, create a program with this problem:
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.
#include <iostream>
#include <cmath>
using namespace std;
class ABCCompany {
public :
int take_off_t1;
int velocity1;
string direction1;
int time_check_distance1;
int take_off_t2;
int velocity2;
string direction2;
int time_check_distance2;
float distance;
void get_Parametres() {
cout << "\nEnter the first plane information: \n";
cout << "Enter take off time the 1-plane[min]: "; cin >> take_off_t1;
cout << "Enter the speed of 1-plane [mil/hour]: "; cin >> velocity1;
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_t2;
cout << "Enter the speed of 2-plane [mil/hour]: "; cin >> velocity2;
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_t1) * velocity1 / 60.0 - (float)(time_check_distance2 - take_off_t2) * velocity2 / 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_t1) * velocity1 / 60.0 + (float)(time_check_distance2 - take_off_t2) * velocity2 / 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_t1) * velocity1 / 60.0, 2) + pow((float)(time_check_distance2 - take_off_t2) * velocity2 / 60.0, 2));
}
cout << "The distance between two planes is: " << distance << " mil.";
}
};
int main () {
ABCCompany flight;
flight.get_Parametres();
flight.distanceBetweenTwoPlanes();
return 0;
}
Comments
Leave a comment