VelizarAvramov

04. Hotel

Nov 5th, 2018
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.02 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04._Hotel
  4. {
  5.     class Hotel
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //A hotel has three types of rooms: studio, double and master suite. The prices are different for the different months
  10.             string month = Console.ReadLine();
  11.             int nigthsCount = int.Parse(Console.ReadLine());
  12.  
  13.             double priceStudio = 0;
  14.             double priceDouble = 0;
  15.             double priceSuite = 0;
  16.  
  17.             switch (month)
  18.             {
  19.                 case "May":
  20.                 case "October":
  21.                     priceStudio = 50;
  22.                     priceDouble = 65;
  23.                     priceSuite = 75;
  24.                     if (nigthsCount > 7)
  25.                     {
  26.                         priceStudio *= 0.95;
  27.                     }
  28.                     break;
  29.                 case "June":
  30.                 case "September":
  31.                     priceStudio = 60;
  32.                     priceDouble = 72;
  33.                     priceSuite = 82;
  34.                     if (nigthsCount > 14)
  35.                     {
  36.                         priceDouble *= 0.90;
  37.                     }
  38.                     break;
  39.                 case "July":
  40.                 case "August":
  41.                 case "December":
  42.                     priceStudio = 68;
  43.                     priceDouble = 77;
  44.                     priceSuite = 89;
  45.                     if (nigthsCount > 14)
  46.                     {
  47.                         priceSuite *= 0.85;
  48.                     }
  49.                     break;
  50.                 default:
  51.                     break;
  52.             }
  53.  
  54.             if ((month == "September" || month == "October") && (nigthsCount > 7))
  55.             {
  56.                 priceStudio *= (1 - (1.0 / nigthsCount));
  57.             }
  58.             Console.WriteLine($"Studio: {nigthsCount* priceStudio:f2} lv.");
  59.             Console.WriteLine($"Double: {nigthsCount * priceDouble:f2} lv.");
  60.             Console.WriteLine($"Suite: {nigthsCount * priceSuite:f2} lv.");
  61.         }
  62.     }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment