Advertisement
denislav5

Untitled

Jul 17th, 2024
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fishingBoat(input) {
  2.   let budget = Number(input[0]);
  3.   let season = input[1];
  4.   let fishermenCount = Number(input[2]);
  5.   let rentPrice = 0;
  6.  
  7.   switch (season) {
  8.     case "Spring":
  9.       rentPrice = 3000;
  10.     case "Summer":
  11.     case "Autumn":
  12.       rentPrice = 4200;
  13.       break;
  14.     case "Winter":
  15.       rentPrice = 2600;
  16.       break;
  17.   }
  18.   if (fishermenCount <= 6) {
  19.     rentPrice *= 0.9;
  20.   } else if (fishermenCount <= 11) {
  21.     rentPrice *= 0.85;
  22.   } else if (fishermenCount > 11) {
  23.     rentPrice *= 0.75;
  24.   }
  25.   if (fishermenCount % 2 === 0 && season !== "Autumn") {
  26.     rentPrice *= 0.95;
  27.   }
  28.   let difference = Math.abs(budget - rentPrice);
  29.   if (budget >= rentPrice) {
  30.     console.log(`Yes! You have ${difference.toFixed(2)} leva left.`);
  31.   } else {
  32.     console.log(`Not enough money! You need ${difference.toFixed(2)} leva.`);
  33.   }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement