40 lines
919 B
C++
40 lines
919 B
C++
#include <iostream>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
double ab;
|
|
double bc;
|
|
double weight;
|
|
cout << "Distance A-B: ";
|
|
cin >> ab;
|
|
cout << "Distance B-C: ";
|
|
cin >> bc;
|
|
cout << "Cargo weight: ";
|
|
cin >> weight;
|
|
|
|
double fuel;
|
|
if (weight <= 500) fuel = 1;
|
|
else if (weight <= 1000) fuel = 4;
|
|
else if (weight <= 1500) fuel = 7;
|
|
else if (weight <= 2000) fuel = 9;
|
|
else {
|
|
cout << "The airplane cannot lift such a load!" << endl;
|
|
return 0;
|
|
}
|
|
|
|
double nAB = ab * fuel;
|
|
double nBC = bc * fuel;
|
|
|
|
if (nAB > 300) {
|
|
cout << "It is impossible to reach point B by flight." << endl;
|
|
}
|
|
else if (nBC > 300) {
|
|
cout << "It is impossible to fly from B to C." << endl;
|
|
}
|
|
else {
|
|
double fill = max(0.0, nBC - (300 - nAB));
|
|
cout << "Minimum refuel at B: " << fill << " liters." << endl;
|
|
}
|
|
return 0;
|
|
}
|