Advertisement
YavorJS

Pipes in a pool

May 31st, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4. static void Main()
  5. {
  6.  
  7. int v = int.Parse(Console.ReadLine());
  8. int p1 = int.Parse(Console.ReadLine());
  9. int p2 = int.Parse(Console.ReadLine());
  10. double h = double.Parse(Console.ReadLine());
  11.  
  12. double volumeP1 = p1 * h;
  13. double volumeP2 = p2 * h;
  14. double totalVolume = volumeP1 + volumeP2;
  15. int percentFull= (int)(totalVolume / v * 100);
  16. int percentP1 = (int)(volumeP1 / totalVolume * 100);
  17. int percentP2 = (int)(volumeP2 / totalVolume * 100);
  18.  
  19. if (totalVolume <= v)
  20. {
  21. Console.WriteLine("The pool is {0}% full. Pipe 1: {1}%. Pipe 2: {2}%.", percentFull, percentP1, percentP2);
  22. }
  23. else
  24. {
  25. double overflow = (totalVolume - v);
  26. Console.WriteLine("For {0} hours the pool overflows with {1} liters.",h,overflow);
  27. }
  28.  
  29.  
  30.  
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement