Advertisement
DidiMilikina

02. Transport Price

Oct 7th, 2017
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.96 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     string one_day_or_night;
  9.     double kilometers, price;
  10.     cin >> kilometers >> one_day_or_night;
  11.  
  12.     double taxi_input_charge = 0.70;
  13.     double taxi_day_charge = 0.79;
  14.     double taxi_night_charge = 0.90;
  15.     double bus_charge = 0.09;
  16.     double train_charge = 0.06;
  17.  
  18.     if (kilometers >= 100)
  19.     {
  20.         if (one_day_or_night == "day" || one_day_or_night == "night")
  21.         {
  22.             price = kilometers * train_charge;
  23.         }
  24.     }
  25.     else if (kilometers >= 20)
  26.     {
  27.         if (one_day_or_night == "day" || one_day_or_night == "night")
  28.         {
  29.             price = kilometers * bus_charge;
  30.         }
  31.     }
  32.     else if (kilometers < 20)
  33.     {
  34.         if (one_day_or_night == "day")
  35.         {
  36.             price = taxi_input_charge + kilometers * taxi_day_charge;
  37.         }
  38.         else if (one_day_or_night == "night")
  39.         {
  40.             price = taxi_input_charge + kilometers * taxi_night_charge;
  41.         }
  42.     }
  43.     cout << fixed << setprecision(2) << price << endl;
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement