ErolKZ

Untitled

Jun 20th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1.  
  2. function solve(input) {
  3.  
  4.  
  5. let month = input[0];
  6.  
  7. let countOfNights = +input[1];
  8.  
  9. let studioSum = 0;
  10.  
  11. let apartmentSum = 0;
  12.  
  13.  
  14.  
  15. if (month === 'May' || month === 'October') {
  16.  
  17. if ( countOfNights <= 7 ) {
  18.  
  19. studioSum = countOfNights * 50;
  20.  
  21. } else if (countOfNights > 7 && countOfNights < 14) {
  22.  
  23. studioSum = countOfNights * 50;
  24. studioSum = studioSum - (studioSum * (5 / 100));
  25.  
  26. } else {
  27.  
  28. studioSum = countOfNights * 50;
  29. studioSum = studioSum - (studioSum * (30 / 100));
  30.  
  31. }
  32.  
  33. apartmentSum = countOfNights * 65;
  34.  
  35. } else if (month === 'June' || month === 'Semptember') {
  36.  
  37. studioSum = countOfNights * 75.20;
  38.  
  39. if ( countOfNights > 14) {
  40.  
  41. studioSum = studioSum - (studioSum * (20 / 100));
  42.  
  43. }
  44.  
  45.  
  46. apartmentSum = countOfNights * 68.70;
  47.  
  48. } else if (month === 'July' || month === 'August') {
  49.  
  50. studioSum = countOfNights * 76;
  51.  
  52. apartmentSum = countOfNights * 77;
  53.  
  54. }
  55.  
  56.  
  57. if (countOfNights > 14) {
  58.  
  59. apartmentSum = apartmentSum - (apartmentSum * (10 / 100));
  60.  
  61. }
  62.  
  63.  
  64.  
  65. console.log(`Apartment: ${apartmentSum.toFixed(2)} lv.`);
  66.  
  67. console.log(`Studio: ${studioSum.toFixed(2)} lv.`);
  68.  
  69.  
  70.  
  71.  
  72. }
  73.  
  74. solve([
  75.  
  76. 'June',
  77. '14',
  78.  
  79. ]);
  80.  
  81.  
  82.  
Advertisement
Add Comment
Please, Sign In to add comment