Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(input) {
- budgetOwned = Number(input.shift());
- nightsCount = Number(input.shift());
- nightPrice = Number(input.shift());
- spendPercentage = Number(input.shift());
- if (nightsCount > 7) {
- nightPrice = nightPrice - nightPrice * 0.05;
- } let nightSum = nightsCount * nightPrice
- let extraExpenses = budgetOwned * spendPercentage / 100
- let totalPrice = nightSum + extraExpenses
- let diff = budgetOwned - totalPrice
- if (budgetOwned >= totalPrice) {
- console.log(`Ivanovi will be left with ${Math.abs(diff.toFixed(2))} leva after vacation.`);
- } else {
- diff = Math.abs(diff)
- console.log(`${(diff.toFixed(2))} leva needed.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment