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
- if (budgetOwned > totalPrice) {
- let diff = totalPrice - budgetOwned;
- console.log(`Ivanovi will be left with ${Math.abs(diff.toFixed(2))} leva after vacation.`);
- } else {
- let diff = totalPrice - budgetOwned;
- console.log(`${Math.abs(diff.toFixed(2))} leva needed.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment