NastySwipy

ConditionalStatementsAndLoopsEx - 04. Hotel

May 20th, 2018
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _02b_ConditionalStatementsAndLoops_Exercises
  4. {
  5.     class ConditionalStatementsAndLoopsEx
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string month = Console.ReadLine();
  10.             int nightsCount = int.Parse(Console.ReadLine());
  11.             double priceStudio = 0;
  12.             double priceDouble = 0;
  13.             double priceSuite = 0;
  14.  
  15.             switch (month)
  16.             {
  17.                 case "May":
  18.                 case "October":
  19.                     priceStudio = 50;
  20.                     priceDouble = 65;
  21.                     priceSuite = 75;
  22.                     break;
  23.                 case "June":
  24.                 case "September":
  25.                     priceStudio = 60;
  26.                     priceDouble = 72;
  27.                     priceSuite = 82;
  28.                     break;
  29.                 case "July":
  30.                 case "August":
  31.                 case "December":
  32.                     priceStudio = 68;
  33.                     priceDouble = 77;
  34.                     priceSuite = 89;
  35.                     break;
  36.             }
  37.            
  38.             if ((month == "May" || month == "October") && nightsCount > 7)
  39.             {
  40.                 priceStudio = priceStudio * 95 / 100;
  41.             }
  42.             if ((month == "June" || month == "September") && nightsCount > 14)
  43.             {
  44.                 priceDouble = priceDouble * 90 / 100;
  45.             }
  46.             if ((month == "July" || month == "August" || month ==  "December") && nightsCount > 14)
  47.             {
  48.                 priceSuite = priceSuite * 85 / 100;
  49.             }
  50.             double totalPriceStudio = priceStudio * nightsCount;
  51.             double totalPriceDouble = priceDouble * nightsCount;
  52.             double totalPriceSuite = priceSuite * nightsCount;
  53.             if ((month == "September" || month == "October") && nightsCount > 7)
  54.             {
  55.  
  56.                 totalPriceStudio -= priceStudio;
  57.             }
  58.             Console.WriteLine($"Studio: {totalPriceStudio:F2} lv.");
  59.             Console.WriteLine($"Double: {totalPriceDouble:F2} lv.");
  60.             Console.WriteLine($"Suite: {totalPriceSuite:F2} lv.");
  61.           }
  62.      }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment