mattnguyen

Untitled

Mar 3rd, 2021
72
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.0;
  13. double priceForApartment = 0.0;
  14.  
  15. switch (month)
  16. {
  17. case "May":
  18. case "October":
  19.  
  20. if (typeOfAccommodation == "Studio")
  21. {
  22. if (nights > 7 && nights <= 14)
  23. {
  24. priceForStudio = (nights * 50) * 0.95;
  25. }
  26. else if (nights > 14)
  27. {
  28. priceForStudio = (nights * 50) * 0.7;
  29. }
  30. else
  31. {
  32. priceForStudio = nights * 50;
  33. }
  34.  
  35.  
  36. }
  37.  
  38.  
  39.  
  40. else if (typeOfAccommodation == "Apartment")
  41. {
  42. if (nights > 14)
  43. {
  44. priceForApartment = (nights * 65) * 0.9;
  45. }
  46. else
  47. {
  48. priceForApartment = nights * 65;
  49. }
  50.  
  51.  
  52. }
  53.  
  54.  
  55.  
  56. break;
  57.  
  58.  
  59. case "June":
  60. case "September":
  61.  
  62. if (typeOfAccommodation == "Studio")
  63. {
  64. if (nights > 14)
  65. {
  66. priceForStudio = (nights * 75.20) * 0.8;
  67. }
  68. else
  69. {
  70. priceForStudio = nights * 75.20;
  71. }
  72.  
  73.  
  74. }
  75. else if (typeOfAccommodation == "Apartment")
  76. {
  77. if (nights > 14)
  78. {
  79. priceForApartment = (nights * 68.70) * 0.9;
  80. }
  81. else
  82. {
  83. priceForApartment = nights * 68.70;
  84. }
  85.  
  86.  
  87. }
  88. break;
  89.  
  90. case "July":
  91. case "August":
  92.  
  93. if (typeOfAccommodation == "Studio")
  94. {
  95. priceForStudio = nights * 76;
  96.  
  97.  
  98. }
  99. else if (typeOfAccommodation == "Apartment")
  100. {
  101. if (nights > 14)
  102. {
  103. priceForApartment = (nights * 77) * 0.9;
  104. }
  105. else
  106. {
  107. priceForApartment = nights * 77;
  108. }
  109.  
  110.  
  111. }
  112. break;
  113.  
  114.  
  115. }
  116.  
  117. Console.WriteLine($"Apartment: {priceForStudio:f2} lv.");
  118. Console.WriteLine($"Apartment: {priceForApartment:f2} lv.");
  119.  
  120. }
  121. }
  122. }
  123.  
Advertisement
Add Comment
Please, Sign In to add comment