Advertisement
Guest User

Untitled

a guest
Jan 17th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. function pipe(args){
  2. let [Volume, PipeOneDebitHour, PipeTwoDebitHour, Hours]= args[0].split('\n').map(Number);
  3.  
  4. let PipeOneDebit = PipeOneDebitHour * Hours;
  5. let PipeTwoDebit = PipeTwoDebitHour * Hours;
  6. let PipesDebit = PipeOneDebit + PipeTwoDebit;
  7.  
  8. if (PipesDebit <= Volume){
  9. let PipeOnePercent = Math.trunc((PipeOneDebit / PipesDebit) * 100);
  10. let PipeTwoPercent =Math.trunc((PipeTwoDebit / PipesDebit) * 100);
  11. let PoolPercent = Math.trunc((PipesDebit / Volume) * 100);
  12. console.log(`The pool is ${PoolPercent}% full. Pipe 1: ${PipeOnePercent}%. Pipe 2: ${PipeTwoPercent}%.`);
  13. } else if (PipesDebit > Volume){
  14. let Overflow = (PipesDebit - Volume);
  15. console.log(`For ${Hours} hours the pool overflows with ${Overflow} liters.`);
  16. }
  17.  
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement