Advertisement
desislava_topuzakova

07. Hotel Room

May 15th, 2023
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _07._Hotel_Room
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string month = Console.ReadLine(); //May, June, July, August, September или October
  10. int nights = int.Parse(Console.ReadLine()); //бр. нощувки
  11.  
  12.  
  13. //1. крайна цена за студио = бр. нощувки (nights) * цена за 1 нощувка в студио
  14. double pricePerNightStudio = 0; //цена за 1 нощувка в студио -> зависи от месеца
  15.  
  16. //2. крайна цена за апартамент = бр. нощувки (nights) * цена за 1 нощувка в апартамент
  17. double pricePerNightApartment = 0; //цена за 1 нощувка в апартамент -> зависи от месеца
  18.  
  19. if (month == "May" || month == "October")
  20. {
  21. pricePerNightStudio = 50;
  22. pricePerNightApartment = 65;
  23. }
  24. else if (month == "June" || month == "September")
  25. {
  26. pricePerNightStudio = 75.20;
  27. pricePerNightApartment = 68.70;
  28. }
  29. else if (month == "July" || month == "August")
  30. {
  31. pricePerNightStudio = 76;
  32. pricePerNightApartment = 77;
  33. }
  34.  
  35. double totalPriceStudio = nights * pricePerNightStudio; //крайна цена за студио
  36. double totalPriceApartment = nights * pricePerNightApartment; //крайна цена за апартамент
  37.  
  38.  
  39. //3. остъпки върху крайни цени
  40. //3.1. отстъпки за студио
  41.  
  42. //повече от 14 нощувки през май и октомври -> -30% за студио
  43. if (nights > 14 && (month == "May" || month == "October"))
  44. {
  45. totalPriceStudio = totalPriceStudio - 0.30 * totalPriceStudio;
  46. }
  47. //повече от 7 нощувки през май и октомври -> -5% за студио
  48. else if (nights > 7 && (month == "May" || month == "October"))
  49. {
  50. totalPriceStudio = totalPriceStudio - 0.05 * totalPriceStudio;
  51. }
  52. //повече от 14 нощувки през юни и септември -> -20% за студио
  53. else if (nights > 14 && (month == "June" || month == "September"))
  54. {
  55. totalPriceStudio = totalPriceStudio - 0.20 * totalPriceStudio;
  56. }
  57.  
  58. //3.2 отстъпки за апартамент
  59. //при повече от 14 нощувки -> -10% за апартамент
  60. if (nights > 14)
  61. {
  62. totalPriceApartment = totalPriceApartment - 0.10 * totalPriceApartment;
  63. }
  64.  
  65. //4. отпечатване
  66. Console.WriteLine($"Apartment: {totalPriceApartment:F2} lv.");
  67. Console.WriteLine($"Studio: {totalPriceStudio:F2} lv.");
  68.  
  69.  
  70. }
  71. }
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement