Advertisement
sanyakasarova

03. Cruise Ship

Jun 6th, 2020
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Program
  5. {
  6.     static void Main()
  7.     {
  8.  
  9.         string cruise = Console.ReadLine();
  10.         string cabin = Console.ReadLine();
  11.         int numOfNights = int.Parse(Console.ReadLine());
  12.  
  13.         double pricePerNight = 0;
  14.  
  15.         switch (cabin)
  16.         {
  17.             case "standard cabin":
  18.                 switch (cruise)
  19.                 {
  20.                     case "Mediterranean":
  21.                         pricePerNight = 27.50;
  22.                         break;
  23.                     case "Adriatic":
  24.                         pricePerNight = 22.99;
  25.                         break;
  26.                     case "Aegean":
  27.                         pricePerNight = 23;
  28.                         break;
  29.                 }
  30.                 break;
  31.             case "cabin with balcony":
  32.                 switch (cruise)
  33.                 {
  34.                     case "Mediterranean":
  35.                         pricePerNight = 30.20;
  36.                         break;
  37.                     case "Adriatic":
  38.                         pricePerNight = 25;
  39.                         break;
  40.                     case "Aegean":
  41.                         pricePerNight = 26.60;
  42.                         break;
  43.                 }
  44.                 break;
  45.             case "apartment":
  46.                 switch (cruise)
  47.                 {
  48.                     case "Mediterranean":
  49.                         pricePerNight = 40.50;
  50.                         break;
  51.                     case "Adriatic":
  52.                         pricePerNight = 34.99;
  53.                         break;
  54.                     case "Aegean":
  55.                         pricePerNight = 39.80;
  56.                         break;
  57.                 }
  58.                 break;
  59.         }
  60.  
  61.         double totalPrice = pricePerNight * numOfNights * 4;
  62.  
  63.  
  64.         if(numOfNights > 7)
  65.         {
  66.             totalPrice -= totalPrice * 0.25;
  67.         }
  68.  
  69.         Console.WriteLine($"Annie's holiday in the {cruise} sea costs {totalPrice:f2} lv.");
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement