Advertisement
v4m4v4

TransportPrice

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