Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pipesInPool(input) {
- let poolVolume = Number(input[0]);
- let firstPipe = Number(input[1]);
- let secondPipe = Number(input[2]);
- let hours = Number(input[3]);
- let firstPipeVolume = firstPipe * hours;
- let secondPipeVolume = secondPipe * hours;
- let totalFill = firstPipeVolume + secondPipeVolume;
- let totalFillPercent = totalFill * 100 / poolVolume;
- let firstPipePercent = firstPipeVolume * 100 / totalFill;
- let secondPipePercent = secondPipeVolume * 100 / totalFill;
- if (totalFill <= poolVolume) {
- console.log(`The pool is ${totalFillPercent.toFixed(2)}% full. Pipe 1: ${firstPipePercent.toFixed(2)}%. Pipe 2: ${secondPipePercent.toFixed(2)}%.`);
- } else {
- console.log(`For ${hours.toFixed(2)} hours the pool overflows with ${totalFill - poolVolume} liters.`)
- }
- }
Add Comment
Please, Sign In to add comment