MiroslavKisov

Transport Price

Jul 18th, 2017
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Transport_Price
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             double TaxyStart = 0.7d;
  14.             double TaxiDay = 0.79d;
  15.             double TaxiNight = 0.9d;
  16.             double Autobus = 0.09d;
  17.             double Train = 0.06d;
  18.             double PriceTaxi = 0.0d;
  19.             double PriceBus = 0.0d;
  20.             double PriceTrain = 0.0d;
  21.             double Distance = double.Parse(Console.ReadLine());
  22.             string daynight = Console.ReadLine();
  23.             if (daynight == "day")
  24.             {
  25.                 if (Distance < 20)
  26.                 {
  27.                     PriceTaxi = TaxyStart + TaxiDay * Distance;
  28.                     Console.WriteLine(PriceTaxi);
  29.                 }
  30.                 else if (Distance >= 20 && Distance < 100)
  31.                 {
  32.                     PriceTaxi = TaxyStart + TaxiDay * Distance;
  33.                     PriceBus = Autobus * Distance;
  34.                     double result = Math.Min(PriceTaxi, PriceBus);
  35.                     Console.WriteLine("{0:0.00}",result);
  36.                 }
  37.                 else if (Distance >= 100)
  38.                 {
  39.                     PriceTaxi = TaxyStart + TaxiDay * Distance;
  40.                     PriceBus = Autobus * Distance;
  41.                     PriceTrain = Train * Distance;
  42.                     double result = Math.Min(PriceTaxi, Math.Min(PriceBus, PriceTrain));
  43.                     Console.WriteLine("{0:0.00}", result);
  44.                 }
  45.             }
  46.             if (daynight == "night")
  47.             {
  48.                 if (Distance < 20)
  49.                 {
  50.                     PriceTaxi = TaxyStart + TaxiNight * Distance;
  51.                     Console.WriteLine("{0:0.00}", PriceTaxi);
  52.                 }
  53.                 else if (Distance >= 20 && Distance < 100)
  54.                 {
  55.                     PriceTaxi = TaxyStart + TaxiNight * Distance;
  56.                     PriceBus = Autobus * Distance;
  57.                     double result = Math.Min(PriceTaxi, PriceBus);
  58.                     Console.WriteLine("{0:0.00}", result);
  59.                 }
  60.                 else if (Distance >= 100)
  61.                 {
  62.                     PriceTaxi = TaxyStart + TaxiNight * Distance;
  63.                     PriceBus = Autobus * Distance;
  64.                     PriceTrain = Train * Distance;
  65.                     double result = Math.Min(PriceTaxi, Math.Min(PriceBus, PriceTrain));
  66.                     Console.WriteLine("{0:0.00}", result);
  67.                 }
  68.             }
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment