Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Решение с тернарен оператор:
- #include <iostream>
- using namespace std;
- int main() {
- double budget;
- cin >> budget;
- string season;
- cin >> season;
- int personCount;
- cin >> personCount;
- const int SEASON_PRICE =
- season == "Winter" ? 2600 :
- season == "Spring" ? 3000 : 4200;
- const double PERSON_COUNT_DISCOUNT =
- personCount > 11 ? 0.25 :
- personCount > 6 ? 0.15 : 0.10;
- double sum = SEASON_PRICE * (1 - PERSON_COUNT_DISCOUNT);
- if (personCount % 2 == 0 && season != "Autumn") {
- sum *= 0.95;
- }
- cout.setf(ios::fixed);
- cout.precision(2);
- if (budget >= sum) {
- cout << "Yes! You have " << budget - sum << " leva left." << endl;
- }
- else {
- cout << "Not enough money! You need " << sum - budget << " leva." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement