Advertisement
alexbancheva

Hotel room

Feb 1st, 2020
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Hotel_Room
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string month = Console.ReadLine();
  10.             int countOfNights = int.Parse(Console.ReadLine());
  11.            
  12.             double studioPerNight = 0;
  13.             double apartmentPerNight = 0;
  14.  
  15.             double totalPriceStudio = 0;
  16.             double totalPriceApartment = 0;
  17.             bool flag = true;
  18.  
  19.             switch (month)
  20.             {
  21.                 case "May":
  22.                     break;
  23.                 case "June":
  24.                     break;
  25.                 case "July":
  26.                     break;
  27.                 case "August":
  28.                     break;
  29.                 case "September":
  30.                     break;
  31.                 case "October":
  32.                     break;
  33.                 default:
  34.                     flag = false;
  35.                     break;
  36.             }
  37.  
  38.             if (flag)
  39.             {
  40.                 if (month == "May" || month == "October")
  41.                 {
  42.  
  43.                     apartmentPerNight = 65;
  44.                     studioPerNight = 50;
  45.  
  46.                     if (countOfNights > 7 && countOfNights <= 14)
  47.                     {
  48.                         studioPerNight = studioPerNight - studioPerNight * 0.05;
  49.                         totalPriceStudio = countOfNights * studioPerNight;
  50.                     }
  51.                     else if (countOfNights >= 14)
  52.                     {
  53.                         studioPerNight = studioPerNight - studioPerNight * 0.3;
  54.                         totalPriceStudio = countOfNights * studioPerNight;
  55.  
  56.                         apartmentPerNight = apartmentPerNight - apartmentPerNight * 0.1;
  57.                         totalPriceApartment = countOfNights * apartmentPerNight;
  58.                     }
  59.  
  60.                         totalPriceApartment = countOfNights * apartmentPerNight;
  61.                         totalPriceStudio = countOfNights * studioPerNight;
  62.  
  63.                 }
  64.                 else if (month == "June" || month == "September")
  65.                 {
  66.                     studioPerNight = 75.20;
  67.                     apartmentPerNight = 68.70;
  68.  
  69.                     if (countOfNights > 14)
  70.                     {
  71.                         studioPerNight = studioPerNight - studioPerNight * 0.2;
  72.                         totalPriceStudio = countOfNights * studioPerNight;
  73.  
  74.                         apartmentPerNight = apartmentPerNight - apartmentPerNight * 0.1;
  75.                         totalPriceApartment = countOfNights * apartmentPerNight;
  76.                     }
  77.  
  78.                         totalPriceStudio = countOfNights * studioPerNight;
  79.                         totalPriceApartment = countOfNights * apartmentPerNight;
  80.  
  81.                 }
  82.                 else if (month == "July" || month == "August")
  83.                 {
  84.                     studioPerNight = 76;
  85.                     apartmentPerNight = 77;
  86.  
  87.                     if (countOfNights > 14)
  88.                     {
  89.                         apartmentPerNight = apartmentPerNight - apartmentPerNight * 0.1;
  90.                         totalPriceApartment = countOfNights * apartmentPerNight;
  91.                     }
  92.  
  93.                         totalPriceStudio = countOfNights * studioPerNight;
  94.                         totalPriceApartment = countOfNights * apartmentPerNight;
  95.                 }
  96.                
  97.             }
  98.  
  99.             Console.WriteLine($"Apartment: {totalPriceApartment:f2} lv.");
  100.             Console.WriteLine($"Studio: {totalPriceStudio:f2} lv.");
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement