Advertisement
Spocoman

01. Pipes In Pool

Dec 18th, 2021
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function PipesInPool(input) {
  2.     let volume = parseFloat(input[0]);
  3.     let pipe1 = parseFloat(input[1]);
  4.     let pipe2 = parseFloat(input[2]);
  5.     let hour = parseFloat(input[3]);
  6.     let poolV = (pipe1 + pipe2) * hour;
  7.     let poolP = poolV / volume;
  8.  
  9.     if (volume >= poolV) {
  10.         console.log(`The pool is ${(poolP * 100).toFixed(2)}% full. Pipe 1: ${(pipe1 / poolV * hour * 100).toFixed(2)}%. Pipe 2: ${(pipe2 / poolV * hour * 100).toFixed(2)}%.`);
  11.     }
  12.     else {
  13.         console.log(`For ${hour} hours the pool overflows with ${(poolV - volume).toFixed(2)} liters.`);
  14.     }
  15. }
  16.  
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement