Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- let budged = +input[0];
- let season = input[1];
- let countFisherman = +input[2];
- let money = 0;
- switch (season) {
- case 'Spring':
- if (countFisherman <= 6) {
- money = 3000 - (3000 * (10 / 100));
- } else if (countFisherman > 7 && countFisherman <= 11) {
- money = 3000 - (3000 * (15 / 100));
- } else if (countFisherman >= 12) {
- money = 3000 - (3000 * (25 / 100));
- }
- break;
- case 'Summer':
- if (countFisherman <= 6) {
- money = 4200 - (4200 * (10 / 100));
- } else if (countFisherman > 7 && countFisherman <= 11) {
- money = 4200 - (4200 * (15 / 100));
- } else if (countFisherman >= 12) {
- money = 4200 - (4200 * (25 / 100));
- }
- break;
- case 'Autumn':
- if (countFisherman <= 6) {
- money = 4200 - (4200 * (10 / 100));
- } else if (countFisherman > 7 && countFisherman <= 11) {
- money = 4200 - (4200 * (15 / 100));
- } else if (countFisherman >= 12) {
- money = 4200 - (4200 * (25 / 100));
- }
- break;
- case 'Winter':
- if (countFisherman <= 6) {
- money = 2600 - (2600 * (10 / 100));
- } else if (countFisherman > 7 && countFisherman <= 11) {
- money = 2600 - (2600 * (15 / 100));
- } else if (countFisherman >= 12) {
- money = 2600 - (2600 * (25 / 100));
- }
- break;
- }
- if (season !== 'Autumn' && countFisherman % 2 == 0) {
- money = money - (money * (5 / 100));
- }
- budged = budged - money;
- if (budged >= 0) {
- console.log(`Yes! You have ${budged.toFixed(2)} leva left.`);
- } else if (budged < 0) {
- budged = Math.abs(budged);
- console.log(`Not enough money! You need ${budged.toFixed(2)} leva.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement