Advertisement
Gromov

Pancake

Dec 11th, 2019
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.01 KB | None | 0 0
  1. #include <iostream>
  2.  
  3.  
  4. using namespace std;
  5.  
  6. int  money, aprod, bprod, amoney;
  7.  
  8. int main()
  9. {
  10.    
  11.    // Ввод данных
  12.    
  13.     cout << "Enter your amount of money: ";
  14.     cin >> money ;
  15.    
  16.     cout << "Enter first pricetag: ";
  17.     cin >> aprod ;
  18.    
  19.     cout << "Enter second pricetag: ";
  20.     cin >> bprod ;
  21.    
  22.     // Убираем продукты, которые не можем себе позволить
  23.    
  24.     if ( aprod > money )
  25.     {
  26.         cout << "\n\nProduct whose price is " << aprod << " euro is too expensive!!!\n\n";
  27.     }
  28.    
  29.     if ( bprod > money )
  30.        {
  31.            cout << "\n\nProduct whose price is " << bprod << " euro is too expensive!!!\n\n";
  32.        }
  33.    
  34.      // Просчет покупки для каждого предмета ОТДЕЛЬНО
  35.    
  36.          if (aprod < money)
  37.         {
  38.             amoney = money / aprod;
  39.             cout << "\nHow many times you can buy first product: " << amoney << endl;
  40.             cout << "\nMoney change: " << money - (aprod * amoney) << " euro" << endl;
  41.         }
  42.    
  43.          if (bprod < money)
  44.         {
  45.             amoney = money / bprod;
  46.             cout << "\nHow many times you can buy second product: " << amoney << endl;
  47.             cout << "\nMoney change: " << money - (bprod * amoney) << " euro" << endl;
  48.         }
  49.    
  50.     // Просчет количества предметов, которые мы сможем купить комплектом, только если мы можем себе позволить оба предмета
  51.    
  52.     if (( aprod < money && bprod < money))
  53.     {
  54.         amoney = money / (aprod + bprod);
  55.         cout << "\nNumber of sets you can buy: " << amoney << endl;
  56.         cout << "\nMoney change: " << money - (amoney * (aprod + bprod)) << " euro" << endl;
  57.     }
  58.     else
  59.     {
  60.         cout << "\n\nYou cant buy set of 2 products! One or two of the products is too expensive!" << endl;
  61.     }
  62.     cin.get();
  63.     system("pause");
  64.     return 0;
  65.    
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement