Advertisement
DraconiusNX

Untitled

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