desislava_topuzakova

03. Movie Destination

Feb 19th, 2022
1,020
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {  
  6.     //входни данни
  7.     double budget;
  8.     cin >> budget;
  9.  
  10.     string destination;
  11.     cin >> destination; //"Dubai", "Sofia" и "London"
  12.  
  13.     string season;
  14.     cin >> season; //"Summer" и "Winter"
  15.  
  16.     int days;
  17.     cin >> days;
  18.  
  19.     //цена за 1 ден -> сезон и дестинация
  20.     double pricePerDay = 0;
  21.     if (season == "Winter")
  22.     {
  23.         //проверка за дестинацията
  24.         if (destination == "Dubai")
  25.         {
  26.             pricePerDay = 45000;
  27.         }
  28.         else if (destination == "Sofia")
  29.         {
  30.             pricePerDay = 17000;
  31.         }
  32.         else if (destination == "London")
  33.         {
  34.             pricePerDay = 24000;
  35.         }
  36.     }
  37.     else if (season == "Summer")
  38.     {
  39.         //проверка за дестинацията
  40.         if (destination == "Dubai")
  41.         {
  42.             pricePerDay = 40000;
  43.         }
  44.         else if (destination == "Sofia")
  45.         {
  46.             pricePerDay = 12500;
  47.         }
  48.         else if (destination == "London")
  49.         {
  50.             pricePerDay = 20250;
  51.         }
  52.     }
  53.  
  54.     //сума за филма = бр. дни * цена за 1 ден
  55.     double totalSum = days * pricePerDay;
  56.  
  57.     //проверка за облекчение или облагане
  58.     if (destination == "Dubai")
  59.     {
  60.         totalSum = totalSum - 0.30 * totalSum; //0.7 * totalSum;
  61.     }
  62.     else if (destination == "Sofia")
  63.     {
  64.         totalSum = totalSum + 0.25 * totalSum; //1.25 * totalSum
  65.     }
  66.  
  67.     // проверка дали бюджетът е достатъчен
  68.     cout.setf(ios::fixed);
  69.     cout.precision(2);
  70.     if (budget >= totalSum)
  71.     {
  72.         //достатъчен
  73.         cout << "The budget for the movie is enough! We have " << budget - totalSum << " leva left!";
  74.     }
  75.     else
  76.     {
  77.         //не е достатъчен
  78.         //budget < totalSum
  79.         cout << "The director needs " << totalSum - budget << " leva more!";
  80.     }
  81.  
  82.  
  83.     return 0;
  84. }
  85.  
Advertisement
Add Comment
Please, Sign In to add comment