Ronnye

Pipes in Pool Solution

Sep 16th, 2016
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Pipes_in_pool
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. var poolVolume = int.Parse(Console.ReadLine());
  14. var pipe1 = int.Parse(Console.ReadLine());
  15. var pipe2 = int.Parse(Console.ReadLine());
  16. var hours = double.Parse(Console.ReadLine());
  17.  
  18. double p1Filled = pipe1 * hours;
  19. double p2Filled = pipe2 * hours;
  20. double allWater = p1Filled + p2Filled;
  21.  
  22. if (allWater > poolVolume)
  23. Console.WriteLine("For {0} hours the pool overflows with {1} liters.", hours, allWater - poolVolume);
  24. else
  25. {
  26. // Всички проценти се свеждат до цяло число (без закръгляне).
  27. // The pool is [x]% full.Pipe 1: [y]%. Pipe 2: [z]%.
  28. int persentagePool = (int)(allWater / poolVolume * 100);
  29. int percentageP1 = (int)(p1Filled / allWater * 100);
  30. int percentageP2 = (int)(p2Filled / allWater * 100);
  31. Console.WriteLine("The pool is {0}% full. Pipe 1: {1}%. Pipe 2: {2}%.", persentagePool, percentageP1, percentageP2);
  32. }
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment