Advertisement
mark79

Ski Trip

Jan 31st, 2020
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int main()
  5. {
  6.     double roomPrice = 18;
  7.     double apartmentPrice = 25;
  8.     double presidentApartmentPrice = 35;
  9.  
  10.     int days;
  11.     string roomType;
  12.     string rate;
  13.  
  14.     cin >> days;
  15.     cin.ignore();
  16.     getline(std::cin, roomType);
  17.     cin >> rate;
  18.     //getline(std::cin, rate);
  19.  
  20.  
  21.     days = days - 1;
  22.     double price = 18;
  23.     if (roomType == "apartment") {
  24.         if (days < 10) {
  25.             price = apartmentPrice * 0.70;
  26.         }
  27.         else if (days <= 15) {
  28.             price = apartmentPrice * 0.65;
  29.         }
  30.         else {
  31.             price = apartmentPrice * 0.50;
  32.         }
  33.     }
  34.     else if (roomType == "president apartment") {
  35.         if (days < 10) {
  36.             price = presidentApartmentPrice * 0.90;
  37.         }
  38.         else if (days <= 15) {
  39.             price = presidentApartmentPrice * 0.85;
  40.         }
  41.         else {
  42.             price = presidentApartmentPrice * 0.80;
  43.         }
  44.     }
  45.  
  46.     if (rate == "positive") {
  47.         price *= 1.25;
  48.     }
  49.     else {
  50.         price *= 0.90;
  51.     }
  52.  
  53.     cout.setf(ios::fixed);
  54.     cout.precision(2);
  55.  
  56.     cout << days * price;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement