Advertisement
Spocoman

05. Journey

Sep 5th, 2023
559
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.89 KB | None | 0 0
  1. Решение с тернарен оператор:
  2.  
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     double budget;
  9.     cin >> budget;
  10.  
  11.     string season;
  12.     cin >> season;
  13.  
  14.     string place = "Hotel";
  15.     string region = "Europe";
  16.  
  17.     double budgetPercertagePrice = 0.9;
  18.  
  19.     if (budget <= 100) {
  20.         region = "Bulgaria";
  21.         if (season == "summer") {
  22.             place = "Camp";
  23.         }
  24.         budgetPercertagePrice = season == "summer" ? 0.3 : 0.7;
  25.     }
  26.     else if (budget > 100 && budget <= 1000) {
  27.         region = "Balkans";
  28.         if (season == "summer") {
  29.             place = "Camp";
  30.         }
  31.         budgetPercertagePrice = season == "summer" ? 0.4 : 0.8;
  32.     }
  33.  
  34.     cout.setf(ios::fixed);
  35.     cout.precision(2);
  36.  
  37.     cout << "Somewhere in " << region << endl;
  38.     cout << place << " - " << budget * budgetPercertagePrice << endl;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement