Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function zadacha(input) {
- let budget = Number(input.shift());
- let season = input.shift();
- let fishersCount = Number(input.shift());
- let price = 0.0;
- if (season === 'Spring') {
- price = 3000;
- } else if (season === 'Summer' || season === 'Autumn') {
- price = 4200;
- } else if (season === 'Winter') {
- price = 2600;
- }
- if (fishersCount <= 6) {
- price *= 0.9;
- } else if (fishersCount <= 11) {
- price *= 0.85;
- } else if (fishersCount > 11) {
- price *= 0.75;
- }
- if (fishersCount % 2 === 0 && season !== 'Autumn') {
- price *= 0.95;
- }
- if (budget >= price) {
- console.log(`Yes! You have ${(budget - price).toFixed(2)} leva left.`)
- } else {
- console.log(`Not enough money! You need ${(price-budget).toFixed(2)} leva.`)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement