Advertisement
Guest User

Untitled

a guest
Nov 30th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ReservationOnFlying
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string classOnTicket = Console.ReadLine(); // класа на билета
  10.             double lengthOnFlight = double.Parse(Console.ReadLine()); // дължина на полета
  11.             int passagersCount = int.Parse(Console.ReadLine()); //брой пътници
  12.  
  13.             decimal priceOnTickets = 0m;
  14.             decimal totalPrice = 0m;
  15.            
  16.  
  17.             switch (classOnTicket)
  18.             {
  19.                 case "Economy":
  20.                     if (lengthOnFlight < 1500)
  21.                     {
  22.                         priceOnTickets = 59.99m;
  23.                     }
  24.                     else if (lengthOnFlight >= 1500 && lengthOnFlight <= 3500)
  25.                     {
  26.                         priceOnTickets = 184.99m;
  27.                     }
  28.                     else if (lengthOnFlight > 3500)
  29.                     {
  30.                         priceOnTickets = 269.99m;
  31.                     }
  32.                      break;
  33.  
  34.                 case "Premium":
  35.                     if (lengthOnFlight < 1500)
  36.                     {
  37.                         priceOnTickets = 179.99m;
  38.                     }
  39.                     else if (lengthOnFlight >= 1500 && lengthOnFlight <= 3500)
  40.                     {
  41.                         priceOnTickets = 279.99m;
  42.                     }
  43.                     else if (lengthOnFlight > 3500)
  44.                     {
  45.                         priceOnTickets = 394.99m;
  46.                     }
  47.                     break;
  48.  
  49.                 case "Business":
  50.                     if (lengthOnFlight < 1500)
  51.                     {
  52.                         priceOnTickets = 254.99m;
  53.                     }
  54.                     else if (lengthOnFlight >= 1500 && lengthOnFlight <= 3500)
  55.                     {
  56.                         priceOnTickets = 379.99m;
  57.                     }
  58.                     else if (lengthOnFlight > 3500)
  59.                     {
  60.                         priceOnTickets = 619.99m;
  61.                     }
  62.                     break;                  
  63.             }
  64.             totalPrice = priceOnTickets * passagersCount;
  65.             if (passagersCount > 6)
  66.                 totalPrice = totalPrice * 0.8m;
  67.             Console.WriteLine($"The total price of the tickets is: {totalPrice :f2} lv.");
  68.         }
  69.     }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement