Advertisement
Spocoman

01. Pipes In Pool

Sep 3rd, 2023
1,118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {  
  6.     double volume, pipe1, pipe2, hours;
  7.     cin >> volume >> pipe1 >> pipe2 >> hours;
  8.  
  9.     double poolV = (pipe1 + pipe2) * hours;
  10.     double poolP = poolV / volume;
  11.  
  12.     cout.setf(ios::fixed);
  13.     cout.precision(2);
  14.  
  15.     if (volume >= poolV) {
  16.         cout << "The pool is " << poolP * 100 << "% full.Pipe 1: " << pipe1 / poolV * hours * 100 << "% .Pipe 2: " << pipe2 / poolV * hours << "% .\n";
  17.     }
  18.     else {
  19.         cout << "For " << hours << " hours the pool overflows with " << poolV - volume << " liters.\n";
  20.     }
  21.  
  22.     return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement