Advertisement
Didart

Fishing Boat

Apr 2nd, 2022
662
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 fishermans = Number(input[2]);
  5.  
  6.     let boatRentPrice = 0;
  7.     switch (season) {
  8.         case `Spring`:
  9.             boatRentPrice = 3000;
  10.             break;
  11.         case `Summer`:
  12.             boatRentPrice = 4200;
  13.         case `Autumn`:
  14.             boatRentPrice = 4200;
  15.             break;
  16.         case `Winter`:
  17.             boatRentPrice = 2600;
  18.             break;
  19.     }
  20.     if (fishermans <= 6) {
  21.         boatRentPrice = boatRentPrice * 0.90;
  22.     } else if (fishermans >= 7 && fishermans <= 11) {
  23.         boatRentPrice = boatRentPrice * 0.85;
  24.     } else if (fishermans >= 12) {
  25.         boatRentPrice = boatRentPrice * 0.75;
  26.     }
  27.     if (fishermans % 2 === 0 && season !== "Autumn") {
  28.         boatRentPrice = boatRentPrice * 0.95;
  29.     }
  30.     if (budget >= boatRentPrice) {
  31.         console.log(`Yes! You have ${(budget - boatRentPrice).toFixed(2)} leva left.`);
  32.     } else {
  33.         console.log(`Not enough money! You need ${(boatRentPrice - budget).toFixed(2)} leva.`);
  34.     }
  35. }
  36. fishingBoat(["3000", "Summer", "11"])
  37.  
  38.  
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement