Advertisement
Angel_Kalinkov

C#ConditionalStatementsAndLoops-Exercises-Hotel_AngelKalinko

Jan 29th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.79 KB | None | 0 0
  1. using System;
  2.  
  3. class Hotel
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         String month = Console.ReadLine().ToLower();
  8.         short nights = short.Parse(Console.ReadLine());
  9.  
  10.         float studioPrice = 0.0f;
  11.         float doublePrice = 0.0f;
  12.         float suitePrice = 0.0f;
  13.  
  14.         switch (month)
  15.         {
  16.             case "may":
  17.             case "october":
  18.                 studioPrice = 50f;
  19.                 doublePrice = 65f;
  20.                 suitePrice = 75f;
  21.                 if (nights > 7)
  22.                 {
  23.                     studioPrice *= 0.95f;
  24.                 }
  25.                 break;
  26.             case "june":
  27.             case "september":
  28.                 studioPrice = 60f;
  29.                 doublePrice = 72f;
  30.                 suitePrice = 82f;
  31.                 if (nights > 14)
  32.                 {
  33.                     doublePrice *= 0.9f;
  34.                 }
  35.                 break;
  36.             case "july":
  37.             case "august":
  38.             case "december":
  39.                 studioPrice = 68f;
  40.                 doublePrice = 77f;
  41.                 suitePrice = 89f;
  42.                 if (nights > 14)
  43.                 {
  44.                     suitePrice *= 0.85f;
  45.                 }
  46.                 break;
  47.             default:
  48.                 break;
  49.         }
  50.         float moneyForStudio = studioPrice * nights;
  51.         float moneyForDouble = doublePrice * nights;
  52.         float moneyForSuite = suitePrice * nights;
  53.  
  54.         if (nights > 7 && (month == "september" || month == "october"))
  55.         {
  56.             moneyForStudio = studioPrice * (nights - 1);
  57.         }
  58.         Console.WriteLine($"Studio: {moneyForStudio:F} lv.");
  59.         Console.WriteLine($"Double: {moneyForDouble:F} lv.");
  60.         Console.WriteLine($"Suite: {moneyForSuite:F} lv.");
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement