Advertisement
bpavlov123bp

PoolPipes

Apr 3rd, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. using System;
  2.  
  3. namespace PoolPipes
  4. {
  5. class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. int poolVolume = int.Parse(Console.ReadLine());
  10. int pipe1 = int.Parse(Console.ReadLine());
  11. int pipe2 = int.Parse(Console.ReadLine());
  12. double hoursWithoutWorkers = double.Parse(Console.ReadLine());
  13. double inputPipe1 = (double)pipe1 * hoursWithoutWorkers;
  14. double inputPipe2 = (double)pipe2 * hoursWithoutWorkers;
  15. double totalInputs = inputPipe1 + inputPipe2;
  16. if(totalInputs <= poolVolume)
  17. {
  18. double percentInput = (totalInputs / (double)poolVolume) * 100.0;
  19. double percentInputPipe1 = (inputPipe1 / (double)totalInputs) * 100.0;
  20. double percentInputPipe2 = (inputPipe2 / (double)totalInputs) * 100.0;
  21. Console.WriteLine("The pool is {0:f0}% full. Pipe 1: {1:f0}%. Pipe 2: {2:f0}%.", Math.Floor(percentInput), Math.Floor(percentInputPipe1),
  22. Math.Floor(percentInputPipe2));
  23. }
  24. else if(totalInputs > poolVolume)
  25. {
  26. double totalOverflow = totalInputs - poolVolume;
  27. Console.WriteLine("For {0} hours the pool overflows with {1} liters.", hoursWithoutWorkers, totalOverflow);
  28. }
  29. Console.Write("Press any key to continue . . . ");
  30. Console.ReadKey(true);
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement