Advertisement
Valantina

CruiseShip/Ex/27.07.2019

Jul 29th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.68 KB | None | 0 0
  1. using System;
  2.  
  3. namespace P03_CruiseShip
  4. {
  5.     class P03_CruiseShip
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string cruise = Console.ReadLine();
  10.             string cabinType = Console.ReadLine();
  11.             int nights = int.Parse(Console.ReadLine());
  12.  
  13.             double price = 0;
  14.  
  15.             switch (cruise)
  16.             {
  17.                 case "Mediterranean":
  18.                     if (cabinType == "standard cabin")
  19.                     {
  20.                         price = nights * 4 * 27.50;
  21.                     }
  22.                     else if (cabinType == "cabin with balcony")
  23.                     {
  24.                         price = nights * 4 * 30.20;
  25.                     }
  26.                     else if (cabinType == "apartment")
  27.                     {
  28.                         price = nights * 4 * 40.50;
  29.                     }
  30.                     else
  31.                     {
  32.                         Console.WriteLine("Invalid cabin type!");
  33.                     }
  34.                     break;
  35.                 case "Adriatic":
  36.                     if (cabinType == "standard cabin")
  37.                     {
  38.                         price = nights * 4 * 22.99;
  39.                     }
  40.                     else if (cabinType == "cabin with balcony")
  41.                     {
  42.                         price = nights * 4 * 25.00;
  43.                     }
  44.                     else if (cabinType == "apartment")
  45.                     {
  46.                         price = nights * 4 * 34.99;
  47.                     }
  48.                     else
  49.                     {
  50.                         Console.WriteLine("Invalid cabin type!");
  51.                     }
  52.                     break;
  53.                 case "Aegean":
  54.                     if (cabinType == "standard cabin")
  55.                     {
  56.                         price = nights * 4 * 23.00;
  57.                     }
  58.                     else if (cabinType == "cabin with balcony")
  59.                     {
  60.                         price = nights * 4 * 26.60;
  61.                     }
  62.                     else if (cabinType == "apartment")
  63.                     {
  64.                         price = nights * 4 * 39.80;
  65.                     }
  66.                     else
  67.                     {
  68.                         Console.WriteLine("Invalid cabin type!");
  69.                     }
  70.                     break;
  71.                 default:
  72.                     Console.WriteLine("Invalid cruise!");
  73.                     break;
  74.             }
  75.  
  76.             if (nights > 7)
  77.             {
  78.                 price = 0.75 * price;
  79.             }
  80.  
  81.             Console.WriteLine($"Annie's holiday in the {cruise} sea costs {price:F2} lv.");
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement