Advertisement
desislava_topuzakova

09. Ski Trip

May 16th, 2023
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _09._Ski_Trip
  4. {
  5. internal class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int days = int.Parse(Console.ReadLine()); //дни престой
  10. string roomType = Console.ReadLine(); //"room for one person", "apartment" или "president apartment"
  11. string feedback = Console.ReadLine(); //"positive" или "negative"
  12.  
  13. //1. крайна цена за престоя = бр. нощувки * цена за 1 нощувка
  14. int nights = days - 1; //бр. нощувки
  15. double pricePerNight = 0; //цена за 1 нощувка -> зависи от тип на стаята
  16.  
  17. //roomType -> серия от проверки за точни стойности
  18. //"room for one person" – 18.00 лв за нощувка
  19. //"apartment" – 25.00 лв за нощувка
  20. //"president apartment" – 35.00 лв за нощувка
  21.  
  22. switch (roomType)
  23. {
  24. case "room for one person":
  25. pricePerNight = 18;
  26. break;
  27. case "apartment":
  28. pricePerNight = 25;
  29. break;
  30. case "president apartment":
  31. pricePerNight = 35;
  32. break;
  33. }
  34.  
  35. double totalPrice = nights * pricePerNight; // крайна цена
  36.  
  37. //2. отстъпки
  38.  
  39. if (roomType == "apartment")
  40. {
  41. //проверка за дните
  42. if (days < 10)
  43. {
  44. //-30%
  45. totalPrice = totalPrice - 0.30 * totalPrice;
  46. }
  47. else if (days >= 10 && days <= 15)
  48. {
  49. //-35%
  50. totalPrice = totalPrice - 0.35 * totalPrice;
  51. }
  52. else if (days > 15)
  53. {
  54. //-50%
  55. totalPrice = totalPrice - 0.50 * totalPrice;
  56. }
  57. }
  58. else if (roomType == "president apartment")
  59. {
  60. //проверка за дните
  61. if (days < 10)
  62. {
  63. //-10%
  64. totalPrice = totalPrice - 0.10 * totalPrice;
  65. }
  66. else if (days >= 10 && days <= 15)
  67. {
  68. //-15%
  69. totalPrice = totalPrice - 0.15 * totalPrice;
  70. }
  71. else if (days > 15)
  72. {
  73. //-20%
  74. totalPrice = totalPrice - 0.20 * totalPrice;
  75. }
  76. }
  77.  
  78. //3. допълнителни отстъпки / намаления -> зависят от feedback
  79. if (feedback == "positive")
  80. {
  81. //+25%
  82. totalPrice = totalPrice + 0.25 * totalPrice;
  83. }
  84. else if (feedback == "negative")
  85. {
  86. //-10%
  87. totalPrice = totalPrice - 0.10 * totalPrice;
  88. }
  89.  
  90. //4. печатане на крайната сума след всички отстъпки
  91. Console.WriteLine($"{totalPrice:F2}");
  92.  
  93. }
  94. }
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement