Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pipesInPool (input) {
- let v = Number(input[0]);
- let P1 = Number(input[1]);
- let P2 = Number(input[2]);
- let h = Number(input[3]);
- let fullP1 = P1 * h;
- let fullP2 = P2 * h;
- let sumOf2 = fullP1 + fullP2;
- if (v > sumOf2) {
- fullPull = sumOf2 * 100 / v;
- percensP1 = (fullP1 * 10 / fullPull).toFixed(2);
- percensP2 = (fullP2 * 10 / fullPull).toFixed(2);
- console.log(`The pool is ${fullPull}% full. Pipe 1: ${percensP1}%. Pipe 2: ${percensP2}%.`);
- } else {
- litersMore = Math.abs(v - sumOf2);
- console.log(`For ${h} hours the pool overflows with ${litersMore.toFixed(2)} liters.`);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement