Advertisement
v4m4v4

PipesPool

Oct 5th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. // TrabiVBasein.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <iomanip>
  7. using namespace std;
  8.  
  9. int main()
  10. {
  11.     double volume, pipe_1, pipe_2;
  12.     double hour;
  13.     cin >> volume >> pipe_1 >> pipe_2 >> hour;
  14.  
  15.     double first_pipe = pipe_1 * hour;
  16.     double second_pipe = pipe_2 * hour;
  17.     double total = first_pipe + second_pipe;
  18.  
  19.     if (total <= volume)
  20.     {
  21.         double prozent = total / volume * 100;
  22.         double prozent_first = first_pipe / total * 100;
  23.         double prozent_second = second_pipe / total * 100;
  24.         cout << "The pool is " << prozent << "% full. Pipe 1: " << prozent_first
  25.              << "%. Pipe 2: " << prozent_second << "%." << endl;
  26.     }
  27.     else if (total > volume)
  28.     {
  29.         double more = total - volume;
  30.         cout << "For " << hour << " hours the pool overflows with "
  31.              << fixed << setprecision(1) << more << " liters." << endl;
  32.     }
  33.     return 0;
  34. }
  35.  
  36. Pipes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement