Advertisement
Guest User

02.PoolPipes - ExamPreparation26032016@SoftUni

a guest
Jan 7th, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.74 KB | None | 0 0
  1. <?php
  2.  
  3. $volume = readline();
  4. $firstFlowRate = readline();
  5. $secondFlowRate = readline();
  6. $hoursMiss = readline();
  7.  
  8. $firstFlowRate *= $hoursMiss;
  9. $secondFlowRate *= $hoursMiss;
  10.  
  11. $totalDebit = $firstFlowRate + $secondFlowRate;
  12. $over = abs($volume - $totalDebit);
  13.  
  14. $full = ceil(($totalDebit / $volume) * 100.0);
  15. $fullFirstPipe = floor(($firstFlowRate / $totalDebit) * 100.0);
  16. $fullSecondPipe = floor(($secondFlowRate / $totalDebit) * 100.0);
  17.  
  18. if($totalDebit <= $volume){
  19.     echo "The pool is $full% full. Pipe 1: $fullFirstPipe%. Pipe 2: $fullSecondPipe%.";
  20. }
  21. else{
  22.     echo "For $hoursMiss hours the pool overflows with $over liters.";
  23.     //echo "For $hoursMiss hours the pool overflows with " . number_format($over, 1) . ' liters.';
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement