Advertisement
Guest User

03. Summer Outfit

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