Liliana797979

pipes in pool

Mar 8th, 2021
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function pool(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.  
  7.     let P1Volume = P1 * H;
  8.     let P2Volume = P2 * H;
  9.     let totalLitres = P1Volume + P2Volume;
  10.     let totalLitresInProcent = totalLitres / 1000 * 100;
  11.     let percentP1 = P1Volume / totalLitres * 100;
  12.     let percentP2 = P2Volume / totalLitres * 100;
  13.     if (totalLitres < V) {
  14.         console.log(`The pool is ${totalLitresInProcent.toFixed(2)}% full. Pipe 1: ${percentP1.toFixed(2)}%. Pipe 2: ${percentP2.toFixed(2)}%.`);
  15.     } else {
  16.         console.log(`For ${H.toFixed(2)} hours the pool overflows with ${(totalLitres - V).toFixed(2)} liters.`);
  17.     }
  18. }
  19.  
  20. pool(["100", "100", "100", "2.5"]);
Advertisement
Add Comment
Please, Sign In to add comment