mattnguyen

Untitled

Mar 2nd, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConditionsExercise
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string month = Console.ReadLine();
  10. int nights = int.Parse(Console.ReadLine());
  11. string typeOfAccommodation = "";
  12. double priceForStudio = 0;
  13. double priceForApartment = 0;
  14.  
  15. switch (month)
  16. {
  17. case "May":
  18. case "October":
  19. if (typeOfAccommodation == "Studio")
  20. {
  21. if (nights > 7 && nights <= 14)
  22. {
  23. priceForStudio = (nights * 50) * 0.95;
  24. }
  25. else if (nights > 14)
  26. {
  27. priceForStudio = (nights * 50) * 0.7;
  28. }
  29. else
  30. {
  31. priceForStudio = nights * 50;
  32. }
  33.  
  34.  
  35. }
  36.  
  37.  
  38.  
  39. else if (typeOfAccommodation == "Apartment")
  40. {
  41. if (nights > 14)
  42. {
  43. priceForApartment = (nights * 65) * 0.9;
  44. }
  45. else
  46. {
  47. priceForApartment = nights * 65;
  48. }
  49.  
  50.  
  51. }
  52.  
  53. Console.WriteLine($"Apartment: {priceForStudio:f2} lv.");
  54. Console.WriteLine($"Apartment: {priceForApartment:f2} lv.");
  55.  
  56. break;
  57.  
  58.  
  59. case "June":
  60. case "September":
  61. if (typeOfAccommodation == "Studio")
  62. {
  63. if (nights > 14)
  64. {
  65. priceForStudio = (nights * 75.20) * 0.8;
  66. }
  67. else
  68. {
  69. priceForStudio = nights * 75.20;
  70. }
  71.  
  72.  
  73. }
  74. else if (typeOfAccommodation == "Apartment")
  75. {
  76. if (nights > 14)
  77. {
  78. priceForApartment = (nights * 68.70) * 0.9;
  79. }
  80. else
  81. {
  82. priceForApartment = nights * 68.70;
  83. }
  84.  
  85.  
  86. }
  87. break;
  88.  
  89. case "July":
  90. case "August":
  91. if (typeOfAccommodation == "Studio")
  92. {
  93. priceForStudio = nights * 76;
  94.  
  95.  
  96. }
  97. else if (typeOfAccommodation == "Apartment")
  98. {
  99. if (nights > 14)
  100. {
  101. priceForApartment = (nights * 77) * 0.9;
  102. }
  103. else
  104. {
  105. priceForApartment = nights * 77;
  106. }
  107.  
  108.  
  109. }
  110. break;
  111.  
  112.  
  113. }
  114.  
  115.  
  116.  
  117. }
  118. }
  119. }
  120.  
Advertisement
Add Comment
Please, Sign In to add comment