Advertisement
emodev

Fishing Boat

Feb 2nd, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function zadacha(input) {
  2.     let budget = Number(input.shift());
  3.     let season = input.shift();
  4.     let fishersCount = Number(input.shift());
  5.  
  6.     let price = 0.0;
  7.  
  8.     if (season === 'Spring') {
  9.         price = 3000;
  10.     } else if (season === 'Summer' || season === 'Autumn') {
  11.         price = 4200;
  12.     } else if (season === 'Winter') {
  13.         price = 2600;
  14.     }
  15.  
  16.  
  17.     if (fishersCount <= 6) {
  18.         price *= 0.9;
  19.     } else if (fishersCount <= 11) {
  20.         price *= 0.85;
  21.     } else if (fishersCount > 11) {
  22.         price *= 0.75;
  23.     }
  24.  
  25.     if (fishersCount % 2 === 0 && season !== 'Autumn') {
  26.         price *= 0.95;
  27.     }
  28.  
  29.     if (budget >= price) {
  30.         console.log(`Yes! You have ${(budget - price).toFixed(2)} leva left.`)
  31.     } else {
  32.         console.log(`Not enough money! You need ${(price-budget).toFixed(2)} leva.`)
  33.     }
  34.  
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement