desislava_topuzakova

03. Travel Agency

Feb 20th, 2021
822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.48 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <math.h>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string town, typePackage, discount;
  9.     cin >> town >> typePackage >> discount;
  10.     int days;
  11.     cin >> days;
  12.     bool isValid = true;
  13.     double pricePerDay = 0;
  14.  
  15.     if (days < 1) {
  16.         cout << "Days must be positive number!" << endl;
  17.     } else {
  18.         if (days > 7) {
  19.             days = days - 1;
  20.         }
  21.         //Банско/Боровец
  22.         if (town == "Bansko" || town == "Borovets") {
  23.             if (typePackage == "noEquipment") {
  24.                 pricePerDay = 80;
  25.                 if (discount == "yes") {
  26.                     pricePerDay = 76;
  27.                 }
  28.             }
  29.             else if (typePackage == "withEquipment") {
  30.                 pricePerDay = 100;
  31.                 if (discount == "yes") {
  32.                     pricePerDay = 90;
  33.                 }
  34.             }
  35.             else {
  36.                 cout << "Invalid input!" << endl;
  37.                 isValid = false;
  38.             }
  39.  
  40.         }
  41.         else if (town == "Varna" || town == "Burgas") {
  42.             if (typePackage == "noBreakfast") {
  43.                 pricePerDay = 100;
  44.                 if (discount == "yes") {
  45.                     pricePerDay = 93;
  46.                 }
  47.             }
  48.             else if (typePackage == "withBreakfast") {
  49.                 pricePerDay = 130;
  50.                 if (discount == "yes") {
  51.                     pricePerDay = 114.40;
  52.                 }
  53.             }
  54.             else {
  55.                 cout << "Invalid input!" << endl;
  56.                 isValid = false;
  57.             }
  58.         }
  59.         else {
  60.             cout << "Invalid input!" << endl;
  61.             isValid = false;
  62.         }
  63.  
  64.         if (isValid == true) {
  65.             double totalPrice = days * pricePerDay;
  66.             cout.setf(ios::fixed);
  67.             cout.precision(2);
  68.             cout << "The price is " << totalPrice << "lv! Have a nice time!" << endl;
  69.         }
  70.  
  71.     }
  72.  
  73.  
  74.  
  75. }
Advertisement
Add Comment
Please, Sign In to add comment