Advertisement
Alexander_B

Hotel Room

Feb 3rd, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.03 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DomashnoHotelRoom
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. // get input --> string month - May, June, July, August, September, October; int nights;
  14.  
  15. string month = Console.ReadLine().ToLower();
  16. int nights = int.Parse(Console.ReadLine());
  17.  
  18. // calculate pricePerNight and allCost for apartment and studio
  19.  
  20. double priceStudioMayOctober = 50.00;
  21. double priceStudioJuneSeptember = 75.20;
  22. double priceStudioJulyAugust = 76.00;
  23.  
  24. double priceApartmentMayOctober = 65.00;
  25. double priceApartmentJuneSeptember = 68.70;
  26. double priceApartmentJulyAugust = 77.00;
  27.  
  28. double allCostStudio = 0.00;
  29. double allCostApartment = 0.00;
  30.  
  31. if (month == "may" || month == "october")
  32. {
  33. allCostStudio = priceStudioMayOctober * nights;
  34. allCostApartment = priceApartmentMayOctober * nights;
  35. }
  36. else if (month == "june" || month == "september")
  37. {
  38. allCostStudio = priceStudioJuneSeptember * nights;
  39. allCostApartment = priceApartmentJuneSeptember * nights;
  40. }
  41. else
  42. {
  43. allCostStudio = priceStudioJulyAugust * nights;
  44. allCostApartment = priceApartmentJulyAugust * nights;
  45. }
  46.  
  47. // calculate discountPercent, according to nights and month
  48.  
  49. double discountPercent = 0.00;
  50. double discountPercentApartmenMoreThanSevenNights = 10;
  51. if (nights > 7 && nights <= 14 && (month == "may" || month == "october"))
  52. {
  53. discountPercent = 5;
  54. }
  55. else if (nights > 14 && (month == "may" || month == "october"))
  56. {
  57. discountPercent = 30;
  58. }
  59. else if (nights > 14 && (month == "june" || month == "september"))
  60. {
  61. discountPercent = 20;
  62. }
  63.  
  64. // calculate discountValue and allCostAftedDiscount for apartmen and studio
  65.  
  66. double discountValueStudio = 0.00;
  67. double discountValueApartment = 0.00;
  68.  
  69. if (nights > 7 && nights <= 14 && (month == "may" || month == "october"))
  70. {
  71. discountValueStudio = (1.00 * discountPercent / 100) * priceStudioMayOctober*nights;
  72. }
  73. else if (nights > 14 && (month == "may" || month == "october"))
  74. {
  75. discountValueStudio = (1.00 * discountPercent / 100) * priceStudioMayOctober*nights;
  76. discountValueApartment = (1.00 * discountPercentApartmenMoreThanSevenNights / 100) * priceApartmentMayOctober*nights;
  77. }
  78. else if (nights > 14 && (month == "june" || month == "september"))
  79. {
  80. discountValueStudio = (1.00 * discountPercent / 100) * priceStudioJuneSeptember*nights;
  81. discountValueApartment = (1.00 * discountPercentApartmenMoreThanSevenNights / 100) * priceApartmentJuneSeptember*nights;
  82. }
  83. else if (nights > 14 && (month == "july" || month == "august"))
  84. {
  85. discountValueApartment = (1.00 * discountPercentApartmenMoreThanSevenNights / 100) * priceApartmentJulyAugust*nights;
  86. }
  87.  
  88. // print result --> “Apartment: {цена за целият престой} lv.”
  89.  
  90.  
  91. switch (month)
  92. {
  93. case "may":
  94. case "october":
  95. if (nights > 14)
  96. {
  97. allCostApartment -= discountValueApartment;
  98. }
  99. else
  100. {
  101. allCostApartment *= 1.00;
  102. }
  103. break;
  104. case "june":
  105. case "september":
  106. if (nights > 14)
  107. {
  108. allCostApartment -= discountValueApartment;
  109. }
  110. else
  111. {
  112. allCostApartment *= 1.00;
  113. }
  114. break;
  115. case "july":
  116. case "august":
  117. if (nights > 14)
  118. {
  119. allCostApartment -= discountValueApartment;
  120. }
  121. else
  122. {
  123. allCostApartment *= 1.00;
  124. }
  125. break;
  126. }
  127. Console.WriteLine($"Apartment: {allCostApartment:f2} lv.");
  128.  
  129. // print result --> “Studio: {цена за целият престой} lv.“
  130.  
  131. switch (month)
  132. {
  133. case "may":
  134. case "october":
  135. if (nights > 7 && nights <= 14)
  136. {
  137. allCostStudio -= discountValueStudio;
  138. }
  139. else if (nights > 14)
  140. {
  141. allCostStudio -= discountValueStudio;
  142. }
  143. else
  144. {
  145. allCostStudio *= 1.00;
  146. }
  147. break;
  148. case "june":
  149. case "september":
  150. if (nights > 14)
  151. {
  152. allCostStudio -= discountValueStudio;
  153. }
  154. else
  155. {
  156. allCostStudio *= 1.00;
  157. }
  158. break;
  159. case "july":
  160. case "august":
  161. allCostStudio *= 1.00;
  162. break;
  163. }
  164. Console.WriteLine($"Studio: {allCostStudio:f2} lv.");
  165. }
  166. }
  167. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement