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