Advertisement
MARINA_GREBENAROVA

Hotel_Room

Sep 29th, 2021
1,056
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Hotel_Room
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string month = Console.ReadLine();
  10.             int nights = int.Parse(Console.ReadLine());
  11.  
  12.             double studio = 0;
  13.             double discountStudio = 0;
  14.             double apartment = 0;
  15.             double discountApartment = 0;
  16.  
  17.  
  18.             switch (month)
  19.             {
  20.                 case "May":
  21.                 case "October":
  22.                     studio = 50;
  23.                     apartment = 65;
  24.                     break;
  25.                 case "June":
  26.                 case "September":
  27.                     studio = 75.20;
  28.                     apartment = 68.70;
  29.                     break;
  30.                 case "July":
  31.                 case "August":
  32.                     studio = 76;
  33.                     apartment = 77;
  34.                     break;
  35.  
  36.             }
  37.             if (nights > 14 && (month == "May" || month == "October"))
  38.             {
  39.                 discountStudio = 0.30;
  40.             }
  41.             else if (nights > 14 && (month == "June" || month == "September"))
  42.             {
  43.                 discountStudio = 0.20;
  44.             }
  45.             else if (nights > 7 && (month == "May" || month == "October"))
  46.             {
  47.                 discountStudio = 0.05;
  48.             }
  49.  
  50.             if (nights > 14)
  51.             {
  52.                 discountApartment = 0.1;
  53.             }
  54.  
  55.             double finalPriceStudio = nights * studio * (1 - discountStudio);
  56.             double finalPriceApartment = nights * apartment * (1 - discountApartment);
  57.             Console.WriteLine($"Apartment: {finalPriceApartment:F2} lv.");
  58.             Console.WriteLine($"Studio: {finalPriceStudio:F2} lv.");
  59.         }
  60.  
  61.     }
  62. }
  63.  
  64.  
  65.  
  66.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement