Advertisement
tsvetelinapasheva

TsvetelinaPasheva/ConditionalStatementsAdvancedExercise/07.HotelRoom

Jan 30th, 2021
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.41 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp8
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.            
  10.            
  11.             const double mayAndOctoberStudioPrice = 50;
  12.             const double mayAndOctoberApartmentPrice = 65;
  13.             const double juneAndSeptemberStudioPrice = 75.20;
  14.             const double juneAndSeptemberApartmentPrice = 68.70;
  15.             const double julyAndAugustStudioPrice = 76;
  16.             const double julyAndAugustApartmentPrice = 77;
  17.             double totalMoneyForApartment = 0;
  18.             double totalMoneyForStudio = 0;
  19.  
  20.            
  21.             string season = Console.ReadLine();
  22.             int nights = int.Parse(Console.ReadLine());
  23.  
  24.             switch (season)
  25.             {
  26.                 case "May":
  27.                 case "October":
  28.                     totalMoneyForApartment = nights * mayAndOctoberApartmentPrice;
  29.                     totalMoneyForStudio = nights * mayAndOctoberStudioPrice;
  30.                     if (nights > 7 && nights < 14)
  31.                     {
  32.                         totalMoneyForStudio = totalMoneyForStudio - (totalMoneyForStudio * 0.05);
  33.                     }
  34.                     else if (nights > 14)
  35.                     {
  36.                         totalMoneyForStudio = totalMoneyForStudio - (totalMoneyForStudio * 0.30);
  37.                     }
  38.                     break;
  39.                 case "June":
  40.                 case "September":
  41.                     totalMoneyForStudio = nights * juneAndSeptemberStudioPrice;
  42.                     totalMoneyForApartment = nights * juneAndSeptemberApartmentPrice;
  43.                     if (nights > 14)
  44.                     {
  45.                         totalMoneyForStudio = totalMoneyForStudio - (totalMoneyForStudio * 0.20);
  46.                     }
  47.                     break;
  48.                 case "July":
  49.                 case "August":
  50.                     totalMoneyForStudio = nights * julyAndAugustStudioPrice;
  51.                     totalMoneyForApartment = nights * julyAndAugustApartmentPrice;
  52.  
  53.                     break;
  54.             }
  55.             if (nights > 14)
  56.             {
  57.                 totalMoneyForApartment = totalMoneyForApartment - (totalMoneyForApartment * 0.10);
  58.             }
  59.  
  60.             Console.WriteLine($"Apartment: {totalMoneyForApartment:f2} lv.");
  61.             Console.WriteLine($"Studio: {totalMoneyForStudio:f2} lv.");
  62.  
  63.  
  64.  
  65.         }
  66.     }
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement