Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Plane{
- public:
- int v_max, v_kr, g_oil_top, g_gr_max, m_gr, dist, m_total;
- int amount_oil;
- double consumption_ave;
- void plane(){
- v_max = 900; //максимальная скорость
- v_kr = 800; //крейсерская
- g_oil_top = 60000;
- g_gr_max = 20000;
- }
- //1 км проедет за 4 минуты при v_max
- //1 км проедет за 4,5 минуты при v_kr
- int calculate_needed_oil(){
- int amount_oil_kr = dist * 20;
- int amount_oil_max = dist * 30;
- if (amount_oil_kr < amount_oil_max)
- amount_oil = amount_oil_kr;
- else amount_oil = amount_oil_max;
- return amount_oil;
- }
- int calculate_max_gruz(){
- int m_dostup = m_gr + (g_oil_top - amount_oil);
- if (m_dostup > g_gr_max)
- return g_gr_max;
- else return m_dostup;
- }
- int calculate_time(){
- int t_max, t_kr;
- t_max = dist / v_max;
- t_kr = dist / v_kr;
- //проверяем хватит ли топлива?
- return t_max ? t_kr : t_max > t_kr;
- }
- };
- int main(){
- Plane p;
- p.plane();
- cout << "Введите растояние" << endl;
- cin >> p.dist;
- cout << "Введите массу груза" << endl;
- cin >> p.m_gr;
- int need_oil = p.calculate_needed_oil();
- if (need_oil <= p.g_oil_top){
- cout << "Необходимо топлива (кг): " << need_oil << endl;
- cout << "Максимальное количество груза (кг): " << p.calculate_max_gruz() << endl;
- }
- else cout << "Необходимо топлива (кг): " << need_oil << " Превышен максимальный объем" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement