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 count_fishermens = Number(input[2]);
- let priceBoat;
- let totalPrice;
- if (season == "Spring") {
- priceBoat = 3000;
- } else if (season == "Summer" || season == "Autumn"){
- priceBoat = 4200;
- } else if (season == "Winter") {
- priceBoat = 2600;
- }
- if (count_fishermens <= 6) {
- totalPrice = priceBoat * 0.90;
- } else if (count_fishermens >= 7 && count_fishermens <= 11) {
- totalPrice = priceBoat * 0.85;
- } else if (count_fishermens >= 12) {
- totalPrice = priceBoat * 0.75;
- }
- if (count_fishermens % 2 === 0 && season != "Autumn") {
- totalPrice *= 0.95;
- } else {
- totalPrice *= 1;
- }
- if (budget >= totalPrice) {
- let money_left = budget - totalPrice;
- console.log(`Yes! You have ${money_left.toFixed(2)} leva left.`);
- } else {
- let needed_money = totalPrice - budget;
- console.log(`Not enough money! You need ${needed_money.toFixed(2)} leva.`);
- }
- }
Add Comment
Please, Sign In to add comment