Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bills(input) {
- let period = Number(input[0]);
- let water = 20;
- let internet = 15;
- let electricity = 0;
- let totalElectricity = 0;
- let others = 0;
- let allOthers = 0;
- for (let i = 1; i <= period; i++) {
- electricity = Number(input[i]);
- totalElectricity += electricity;
- others = (water + internet + electricity) +
- (water + internet + electricity) * 20 / 100;
- allOthers += others;
- }
- let costs = totalElectricity + (water + internet) * period + allOthers;
- let averageCosts = costs / period;
- console.log(`Electricity: ${totalElectricity.toFixed(2)} lv`);
- console.log(`Water: ${(water * period).toFixed(2)} lv`);
- console.log(`Internet: ${(internet * period).toFixed(2)} lv`);
- console.log(`Other: ${allOthers.toFixed(2)} lv`);
- console.log(`Average: ${averageCosts.toFixed(2)} lv`);
- }
Advertisement
Add Comment
Please, Sign In to add comment