Advertisement
tamniakav

Problem 4. Hotel

Sep 23rd, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Hotel
  8. {
  9.     class Hotel
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string month = Console.ReadLine();
  14.             int nights = int.Parse(Console.ReadLine());
  15.  
  16.             double studio = 0.00;
  17.             double doubleRoom = 0.00;
  18.             double suite = 0.00;
  19.  
  20.             switch (month)
  21.             {
  22.                 case "May":
  23.                 case "October":
  24.                     studio = 50;
  25.                     doubleRoom = 65;
  26.                     suite = 75;
  27.  
  28.                     if (nights > 7)
  29.                     {
  30.                         studio *= 0.95;
  31.                     }
  32.                     break;
  33.                 case "June":
  34.                 case "September":
  35.                     studio = 60;
  36.                     doubleRoom = 72;
  37.                     suite = 82;
  38.  
  39.                     if (nights > 14)
  40.                     {
  41.                         doubleRoom *= 0.90;
  42.                     }
  43.                     break;
  44.  
  45.                 case "July":
  46.                 case "August":
  47.                 case "December":
  48.                     studio = 68;
  49.                     doubleRoom = 77;
  50.                     suite = 89;
  51.  
  52.                     if (nights > 14)
  53.                     {
  54.                         suite *= 0.85;
  55.                     }
  56.                     break;
  57.             }
  58.  
  59.             double priceForStudio = nights * studio;
  60.             double priceForDouble = nights * doubleRoom;
  61.             double priceForSuite = nights * suite;
  62.  
  63.             if ((month == "October" || month == "September") && nights > 7)
  64.             {
  65.                 priceForStudio -= studio;
  66.             }
  67.  
  68.             Console.WriteLine($"Studio: {priceForStudio:f2} lv.");
  69.             Console.WriteLine($"Double: {priceForDouble:f2} lv.");
  70.             Console.WriteLine($"Suite: {priceForSuite:f2} lv.");
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement