Advertisement
GalinaKG

Untitled

Feb 16th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. function pipesInPool (input) {
  2. let v = Number(input[0]);
  3. let P1 = Number(input[1]);
  4. let P2 = Number(input[2]);
  5. let h = Number(input[3]);
  6. let fullP1 = P1 * h;
  7. let fullP2 = P2 * h;
  8. let sumOf2 = fullP1 + fullP2;
  9.  
  10. if (v > sumOf2) {
  11. fullPull = sumOf2 * 100 / v;
  12. percensP1 = (fullP1 * 10 / fullPull).toFixed(2);
  13. percensP2 = (fullP2 * 10 / fullPull).toFixed(2);
  14. console.log(`The pool is ${fullPull}% full. Pipe 1: ${percensP1}%. Pipe 2: ${percensP2}%.`);
  15. } else {
  16. litersMore = Math.abs(v - sumOf2);
  17. console.log(`For ${h} hours the pool overflows with ${litersMore.toFixed(2)} liters.`);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement