Advertisement
ErolKZ

Untitled

Jun 20th, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. function solve(input) {
  2.  
  3. let budged = +input[0];
  4.  
  5. let season = input[1];
  6.  
  7. let countFisherman = +input[2];
  8.  
  9. let money = 0;
  10.  
  11.  
  12. switch (season) {
  13.  
  14.  
  15.  
  16. case 'Spring':
  17.  
  18. if (countFisherman <= 6) {
  19.  
  20. money = 3000 - (3000 * (10 / 100));
  21.  
  22. } else if (countFisherman > 7 && countFisherman <= 11) {
  23.  
  24. money = 3000 - (3000 * (15 / 100));
  25.  
  26. } else if (countFisherman >= 12) {
  27.  
  28. money = 3000 - (3000 * (25 / 100));
  29.  
  30. }
  31.  
  32. break;
  33.  
  34.  
  35. case 'Summer':
  36.  
  37. if (countFisherman <= 6) {
  38.  
  39. money = 4200 - (4200 * (10 / 100));
  40.  
  41. } else if (countFisherman > 7 && countFisherman <= 11) {
  42.  
  43. money = 4200 - (4200 * (15 / 100));
  44.  
  45. } else if (countFisherman >= 12) {
  46.  
  47. money = 4200 - (4200 * (25 / 100));
  48.  
  49. }
  50.  
  51. break;
  52.  
  53.  
  54.  
  55. case 'Autumn':
  56.  
  57. if (countFisherman <= 6) {
  58.  
  59. money = 4200 - (4200 * (10 / 100));
  60.  
  61. } else if (countFisherman > 7 && countFisherman <= 11) {
  62.  
  63. money = 4200 - (4200 * (15 / 100));
  64.  
  65. } else if (countFisherman >= 12) {
  66.  
  67. money = 4200 - (4200 * (25 / 100));
  68.  
  69. }
  70.  
  71. break;
  72.  
  73.  
  74. case 'Winter':
  75.  
  76. if (countFisherman <= 6) {
  77.  
  78. money = 2600 - (2600 * (10 / 100));
  79.  
  80. } else if (countFisherman > 7 && countFisherman <= 11) {
  81.  
  82. money = 2600 - (2600 * (15 / 100));
  83.  
  84. } else if (countFisherman >= 12) {
  85.  
  86. money = 2600 - (2600 * (25 / 100));
  87.  
  88. }
  89.  
  90. break;
  91.  
  92. }
  93.  
  94. if (season !== 'Autumn' && countFisherman % 2 == 0) {
  95.  
  96. money = money - (money * (5 / 100));
  97.  
  98. }
  99.  
  100. budged = budged - money;
  101.  
  102.  
  103. if (budged >= 0) {
  104.  
  105. console.log(`Yes! You have ${budged.toFixed(2)} leva left.`);
  106.  
  107. } else if (budged < 0) {
  108.  
  109. budged = Math.abs(budged);
  110.  
  111. console.log(`Not enough money! You need ${budged.toFixed(2)} leva.`);
  112.  
  113. }
  114.  
  115.  
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement