Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function pool(input) {
- let V = Number(input[0]);
- let P1 = Number(input[1]);
- let P2 = Number(input[2]);
- let H = Number(input[3]);
- let P1Volume = P1 * H;
- let P2Volume = P2 * H;
- let totalLitres = P1Volume + P2Volume;
- let totalLitresInProcent = totalLitres / 1000 * 100;
- let percentP1 = P1Volume / totalLitres * 100;
- let percentP2 = P2Volume / totalLitres * 100;
- if (totalLitres < V) {
- console.log(`The pool is ${totalLitresInProcent.toFixed(2)}% full. Pipe 1: ${percentP1.toFixed(2)}%. Pipe 2: ${percentP2.toFixed(2)}%.`);
- } else {
- console.log(`For ${H.toFixed(2)} hours the pool overflows with ${(totalLitres - V).toFixed(2)} liters.`);
- }
- }
- pool(["100", "100", "100", "2.5"]);
Advertisement
Add Comment
Please, Sign In to add comment