Advertisement
DidiMilikina

16.

Sep 24th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     double distance;
  8.     string time_of_day;
  9.  
  10.     cin >> distance;
  11.     cin >> time_of_day;
  12.  
  13.  
  14.     double taxi_initial_price = 0.7;
  15.     double taxi_day_price = 0.79;
  16.     double taxi_night_price = 0.9;
  17.     double bus = 0.09;
  18.     double train = 0.06;
  19.  
  20.     if (distance >= 100)
  21.     {
  22.         //Train
  23.         cout << distance * train << endl;
  24.     }
  25.     else if (distance >= 20)
  26.     {
  27.         //Bus
  28.         cout << distance * bus << endl;
  29.     }
  30.     else
  31.     {
  32.         //Taxi
  33.         if (time_of_day == "day")
  34.         {
  35.             cout << taxi_initial_price + distance * taxi_day_price << endl;
  36.         }
  37.         else if (time_of_day == "night")
  38.         {
  39.             cout << taxi_initial_price + distance * taxi_night_price << endl;
  40.         }
  41.     }
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement