Advertisement
Valantina

TravelAgency/Exam

Jul 9th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.26 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P03_TravelAgency
  4. {
  5.     class P03_TravelAgency
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string town = Console.ReadLine();
  10.             string pack = Console.ReadLine();
  11.             bool hasVIP = Console.ReadLine() == "yes";
  12.             int days = int.Parse(Console.ReadLine());
  13.             bool isValid = false;
  14.  
  15.             double price = 0.0;
  16.  
  17.             if (days > 7)
  18.             {
  19.                 days--;
  20.             }
  21.  
  22.             switch (town)
  23.             {
  24.                 case "Bansko":
  25.                 case "Borovets":
  26.                     if (hasVIP)
  27.                     {
  28.                         if ("noEquipment" == pack)
  29.                         {
  30.                             price = 80 * 0.95;
  31.                         }
  32.                         else if ("withEquipment" == pack)
  33.                         {
  34.                             price = 100 * 0.9;
  35.                         }
  36.                         else
  37.                         {
  38.                             isValid = true;
  39.                         }
  40.                     }
  41.                     else
  42.                     {
  43.                         if ("noEquipment" == pack)
  44.                         {
  45.                             price = 80;
  46.                         }
  47.                         else if ("withEquipment" == pack)
  48.                         {
  49.                             price = 100;
  50.                         }
  51.                         else
  52.                         {
  53.                             isValid = true;
  54.                         }
  55.                     }
  56.                     break;
  57.                 case "Varna":
  58.                 case "Burgas":
  59.                     if (hasVIP)
  60.                     {
  61.                         if ("withBreakfast" == pack)
  62.                         {
  63.                             price = 130 * 0.88;
  64.                         }
  65.                         else if ("noBreakfast" == pack)
  66.                         {
  67.                             price = 100 * 0.92;
  68.                         }
  69.                         else
  70.                         {
  71.                             isValid = true;
  72.                         }
  73.                     }
  74.                     else
  75.                     {
  76.                         if ("withBreakfast" == pack)
  77.                         {
  78.                             price = 130;
  79.                         }
  80.                         else if ("noBreakfast" == pack)
  81.                         {
  82.                             price = 100;
  83.                         }
  84.                         else
  85.                         {
  86.                             isValid = true;
  87.                         }
  88.                     }
  89.                     break;
  90.                 default:
  91.                     isValid = true;
  92.                     break;
  93.             }
  94.             if (isValid)
  95.             {
  96.                 Console.WriteLine("Invalid input!");
  97.             }
  98.             else if (days < 1)
  99.             {
  100.                 Console.WriteLine("Days must be positive number!");
  101.             }
  102.             else
  103.             {
  104.                 double finalPrice = days * price;
  105.                 Console.WriteLine($"The price is {finalPrice:F2}lv! Have a nice time!");
  106.             }
  107.         }
  108.     }
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement