Advertisement
Liliana797979

fishing boat

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