Advertisement
finderabc

04. Transport Price - Conditional Statements - More Exercise

Mar 23rd, 2020
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp8
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int km = int.Parse(Console.ReadLine());
  10.             string dayOrNight = Console.ReadLine();
  11.             double taxiPrice = 0.70;
  12.             double bus = 0.09;
  13.             double train = 0.06;
  14.             if (km < 20 && km>0) // TAXI CHECK
  15.             {
  16.                 if (dayOrNight == "day")
  17.                 {
  18.                     double tarifa = 0.79;
  19.                     double price = taxiPrice + km * tarifa;
  20.                     Console.WriteLine($"{price:f2}");
  21.                 }
  22.                 else if (dayOrNight == "night")
  23.                 {
  24.                     double tarifa = 0.90;
  25.                     double price = taxiPrice + km * tarifa;
  26.                     Console.WriteLine($"{price:f2}");
  27.                 }
  28.             }
  29.  
  30.             else if (km >= 100)
  31.             {
  32.                 if (dayOrNight == "day" || dayOrNight == "night")
  33.                 {
  34.                     double price = km * train;
  35.                     Console.WriteLine($"{price:f2}");
  36.                 }
  37.                
  38.  
  39.             }if (km >= 20 && km <100)
  40.                 {
  41.                     if (dayOrNight == "day" || dayOrNight == "night")
  42.                     {
  43.                         double price = km * bus;
  44.                         Console.WriteLine($"{price:f2}");
  45.                     }
  46.  
  47.                 }
  48.            
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement