-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise04.FishingBoat.js
More file actions
34 lines (27 loc) · 976 Bytes
/
Exercise04.FishingBoat.js
File metadata and controls
34 lines (27 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function fishingBoat (budget, season, fishersCount){
let boatPrice = 0;
switch (season) {
case `Spring`: boatPrice = 3000; break;
case `Summer`: boatPrice = 4200; break;
case `Autumn`: boatPrice = 4200; break;
case `Winter`: boatPrice = 2600; break;
}
let discount = 0;
if (fishersCount <= 6){
discount = boatPrice * 0.10;
} else if (fishersCount >= 7 && fishersCount <= 11){
discount = boatPrice * 0.15;
} else if (fishersCount >= 12) {
discount = boatPrice * 0.25;
}
let finalPrice = boatPrice - discount;
if (fishersCount % 2 === 0 && season != `Autumn`){
finalPrice *= 0.95;
}
if (budget >= finalPrice){
console.log(`Yes! You have ${(budget - finalPrice).toFixed(2)} leva left.`);
} else {
console.log(`Not enough money! You need ${(finalPrice - budget).toFixed(2)} leva.`);
}
}
fishingBoat(2000, "Winter", 13);