Advertisement
DraconiusNX

Untitled

Sep 18th, 2022
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function fillThePool(data) {
  2.     var volumePool = Number(data[0]);
  3.     var pipe1 = Number(data[1]);
  4.     var pipe2 = Number(data[2]);
  5.     var hoursMissing = Number(data[3]);
  6.  
  7.     var totalWater = pipe1 * hoursMissing + pipe2 * hoursMissing;
  8.     var Percent = volumePool / 100;
  9.     var pipe1PercentTotal = (pipe1 * hoursMissing) / Percent;
  10.     var pipe2PercentTotal = (pipe2 * hoursMissing) / Percent;
  11.     var totalPercent = pipe1PercentTotal + pipe2PercentTotal;
  12.     var pipe1PercentSingle = ((pipe1 * hoursMissing) * 100) / totalWater;
  13.     var pipe2PercentSingle = ((pipe2 * hoursMissing) * 100) / totalWater;
  14.     if (totalWater <= volumePool) {
  15.         console.log(`The pool is ${totalPercent.toFixed(2)}% full. Pipe 1: ${pipe1PercentSingle.toFixed(2)}%. Pipe 2: ${pipe2PercentSingle.toFixed(2)}%`);
  16.     } else {
  17.         var overflow = totalWater - volumePool;
  18.         console.log(`For ${hoursMissing} hours the pool overflows with ${overflow.toFixed(2)} liters.`);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement