Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- int main()
- {
- enum sumRange { rangeA = 2000, rangeB = 1500, rangeC = 1000 };
- enum discount { A = 10, B = 7, C = 5};
- float haveMoney{ 0 };
- float cost{ 0 };
- int discountPercent{0};
- std::cout << "Enter money sum you have\n";
- std::cin >> haveMoney;
- std::cout << "Enter cost of goods you witsh to buy\n";
- std::cin >> cost;
- if (cost >= rangeA)
- {
- discountPercent = discount::A;
- }
- else if ( cost >= rangeB)
- {
- discountPercent = discount::B;
- }
- else if (cost >= rangeC)
- {
- discountPercent = discount::C;
- }
- cost -= cost * discountPercent / 100.0;
- if (discountPercent)
- {
- std::cout << "Cost with discount is " << cost << '\n';
- }
- else
- {
- std::cout << "Cost WITHOUT discount is " << cost << '\n';
- }
- if (cost > haveMoney)
- {
- std::cout << "Oops! You haven't enough money to pay!\n";
- std::cout << "Find another " << cost - haveMoney << " $$$ and try again!\n";
- }
- else
- {
- std::cout << "You have enough money!\n";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement