TZinovieva

Energy Booster

Jan 3rd, 2023
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function energyBooster(input) {
  2.     let fruit = input[0];
  3.     let size = input[1];
  4.     let quantity = Number(input[2]);
  5.  
  6.     let price = 0;
  7.  
  8.     switch(size) {
  9.         case "small":
  10.             if (fruit === "Watermelon") {
  11.                 price = 56 * 2;
  12.             } else if (fruit === "Mango") {
  13.                 price = 36.66 * 2;
  14.             } else if (fruit === "Pineapple") {
  15.                 price = 42.10 * 2;
  16.             } else if (fruit === "Raspberry") {
  17.                 price = 20 * 2;
  18.             }
  19.             break;
  20.         case "big":
  21.             if (fruit === "Watermelon") {
  22.                 price = 28.70 * 5;
  23.             } else if (fruit === "Mango") {
  24.                 price = 19.60 * 5;
  25.             } else if (fruit === "Pineapple") {
  26.                 price = 24.80 * 5;
  27.             } else if (fruit === "Raspberry") {
  28.                 price = 15.20 * 5;
  29.             }
  30.             break;
  31.     }
  32.     let totalPrice = price * quantity;
  33.  
  34.     if (totalPrice >= 400 && totalPrice <= 1000) {
  35.         totalPrice -= totalPrice * 0.15;
  36.     }
  37.     if (totalPrice > 1000) {
  38.         totalPrice -= totalPrice * 0.50;
  39.     }
  40.     console.log(`${totalPrice.toFixed(2)} lv.`);
  41. }
Advertisement
Add Comment
Please, Sign In to add comment