Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fishingBoat(input) {
- let budget = Number(input[0]);
- let season = input[1];
- let fishermenCount = Number(input[2]);
- let rentPrice = 0;
- switch (season) {
- case "Spring":
- rentPrice = 3000;
- case "Summer":
- case "Autumn":
- rentPrice = 4200;
- break;
- case "Winter":
- rentPrice = 2600;
- break;
- }
- if (fishermenCount <= 6) {
- rentPrice *= 0.9;
- } else if (fishermenCount <= 11) {
- rentPrice *= 0.85;
- } else if (fishermenCount > 11) {
- rentPrice *= 0.75;
- }
- if (fishermenCount % 2 === 0 && season !== "Autumn") {
- rentPrice *= 0.95;
- }
- let difference = Math.abs(budget - rentPrice);
- if (budget >= rentPrice) {
- console.log(`Yes! You have ${difference.toFixed(2)} leva left.`);
- } else {
- console.log(`Not enough money! You need ${difference.toFixed(2)} leva.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement