Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int money, aprod, bprod, amoney;
- int main()
- {
- // Ввод данных
- cout << "Enter your amount of money: ";
- cin >> money ;
- cout << "Enter first pricetag: ";
- cin >> aprod ;
- cout << "Enter second pricetag: ";
- cin >> bprod ;
- // Убираем продукты, которые не можем себе позволить
- if ( aprod > money )
- {
- cout << "\n\nProduct whose price is " << aprod << " euro is too expensive!!!\n\n";
- }
- if ( bprod > money )
- {
- cout << "\n\nProduct whose price is " << bprod << " euro is too expensive!!!\n\n";
- }
- // Просчет покупки для каждого предмета ОТДЕЛЬНО
- if (aprod < money)
- {
- amoney = money / aprod;
- cout << "\nHow many times you can buy first product: " << amoney << endl;
- cout << "\nMoney change: " << money - (aprod * amoney) << " euro" << endl;
- }
- if (bprod < money)
- {
- amoney = money / bprod;
- cout << "\nHow many times you can buy second product: " << amoney << endl;
- cout << "\nMoney change: " << money - (bprod * amoney) << " euro" << endl;
- }
- // Просчет количества предметов, которые мы сможем купить комплектом, только если мы можем себе позволить оба предмета
- if (( aprod < money && bprod < money))
- {
- amoney = money / (aprod + bprod);
- cout << "\nNumber of sets you can buy: " << amoney << endl;
- cout << "\nMoney change: " << money - (amoney * (aprod + bprod)) << " euro" << endl;
- }
- else
- {
- cout << "\n\nYou cant buy set of 2 products! One or two of the products is too expensive!" << endl;
- }
- cin.get();
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement