Advertisement
Angel_Kalinkov

PBE-28August2016-HotelRoom_AngelKalinkov

Mar 20th, 2018
346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.84 KB | None | 0 0
  1. using System;
  2.  
  3. class HotelRoom
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         string month = Console.ReadLine().ToLower();
  8.         int nights = int.Parse(Console.ReadLine());
  9.  
  10.         double studioPrice = 50.00;
  11.         double apartmentPrice = 65.00;
  12.         double studioDiscount = 0.00;
  13.         double apartmentDiscount = 0.00;
  14.  
  15.         switch (month)
  16.         {
  17.             case "may":
  18.             case "october":
  19.                 if (nights > 14)
  20.                 {
  21.                     studioDiscount = 0.30;
  22.                     apartmentDiscount = 0.10;
  23.                 }
  24.                 else if (nights > 7)
  25.                 {
  26.                     studioDiscount = 0.05;
  27.                 }
  28.                 break;
  29.             case "june":
  30.             case "september":
  31.                 studioPrice = 75.20;
  32.                 apartmentPrice = 68.70;
  33.                 if (nights > 14)
  34.                 {
  35.                     studioDiscount = 0.20;
  36.                     apartmentDiscount = 0.10;
  37.                 }
  38.                 break;
  39.             case "july":
  40.             case "august":
  41.                 studioPrice = 76.00;
  42.                 apartmentPrice = 77.00;
  43.                 if (nights > 14)
  44.                 {
  45.                     apartmentDiscount = 0.10;
  46.                 }
  47.                 break;
  48.             default:
  49.                 Console.WriteLine("Off season");
  50.                 break;
  51.         }
  52.  
  53.         double moneyForStudio = nights * studioPrice;
  54.         moneyForStudio = moneyForStudio - (moneyForStudio * studioDiscount);
  55.         double moneyForApartment = nights * apartmentPrice;
  56.         moneyForApartment = moneyForApartment - (moneyForApartment * apartmentDiscount);
  57.  
  58.         Console.WriteLine($"Apartment: {moneyForApartment:F} lv.");
  59.         Console.WriteLine($"Studio: {moneyForStudio:F} lv.");
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement