Untitled
function fishingBoat (input) { let groupBudget = Number(input[0]); let season = (input[1]); let groupNumber = Number(input[2]); let finalPrice = 0; switch (season) { case "Spring": finalPrice = 3000; break; case "Summer": finalPrice = 4200; break; case "Autumn": finalPrice = 4200; break; case "Winter": finalPrice = 2600; break; } if (groupNumber <= 6) { finalPrice *= 0.9; } else if (groupNumber <= 11) { finalPrice *= 0.85; } else if (groupNumber > 11) { finalPrice *= 0.75; } if (groupNumber % 2 === 0 && season !== "Autumn") { finalPrice *= 0.95; } if (groupBudget >= finalPrice) { let moneyLeft = groupBudget - finalPrice; console.log(`Yes! You have ${moneyLeft.toFixed(2)} leva left.`); } else { let moneyNeeded = finalPrice - groupBudget; console.log(`Not enough money! You need ${moneyNeeded.toFixed(2)} leva.`); } }
Leave a Comment