Teo10

Untitled

Sep 4th, 2019
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(input) {
  2.  
  3.     budgetOwned = Number(input.shift());
  4.     nightsCount = Number(input.shift());
  5.     nightPrice = Number(input.shift());
  6.     spendPercentage = Number(input.shift());
  7.  
  8.     if (nightsCount > 7) {
  9.         nightPrice = nightPrice - nightPrice * 0.05;
  10.     } let nightSum = nightsCount * nightPrice
  11.     let extraExpenses = budgetOwned * spendPercentage / 100
  12.     let totalPrice = nightSum + extraExpenses
  13.     let diff = budgetOwned - totalPrice
  14.  
  15.     if (budgetOwned >= totalPrice) {
  16.         console.log(`Ivanovi will be left with ${Math.abs(diff.toFixed(2))} leva after vacation.`);
  17.     } else {
  18.         diff = Math.abs(diff)
  19.         console.log(`${(diff.toFixed(2))} leva needed.`);
  20.  
  21.     }
  22.  
  23. }
Advertisement
Add Comment
Please, Sign In to add comment