Advertisement
tripplesteel

Untitled

Jan 29th, 2022
770
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function dayOfWeek(input){
  2.     const budget = Number(input[0]);
  3.     const season = input[1];
  4.     const fishermens = Number(input[2]);
  5.  
  6.     let totalNedded = 0;
  7.     let cost;
  8.     switch(season){
  9.         case "Spring":
  10.             cost = 3000;
  11.         break;
  12.         case "Summer":
  13.         case "Autumn":
  14.             cost = 4200;
  15.         break;
  16.         case "Winter":
  17.             cost = 2600;
  18.         break;
  19.     }
  20.     if(fishermens >= 1 && fishermens<=6){
  21.         totalNedded += (cost - (cost * 0.1));
  22.     } else if (fishermens >= 7 && fishermens<=11){
  23.         totalNedded += cost - (cost * 0.15);
  24.     } else if (fishermens >= 12){
  25.         totalNedded += (cost - (cost * 0.25));
  26.     }
  27.  
  28.     if(fishermens % 2 == 0 && season != "Autumn"){
  29.         totalNedded += totalNedded - (totalNedded * 0.05);
  30.     }
  31.  
  32.     let left = Math.abs(totalNedded - budget).toFixed(2);
  33.     if(totalNedded <= budget){
  34.         console.log(`Yes! You have ${left} leva left.`);
  35.     } else {
  36.         console.log(`Not enough money! You need ${left} leva.`);
  37.     }
  38.  
  39. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement