Advertisement
Jann24

Zad2

Nov 20th, 2024
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.57 KB | None | 0 0
  1. int V = int.Parse(Console.ReadLine());
  2. int P1 = int.Parse(Console.ReadLine());
  3. int P2 = int.Parse(Console.ReadLine());
  4. double H = double.Parse(Console.ReadLine());
  5.  
  6. int filled = (int)((P1 + P2) * H);
  7. int percentFilled = filled * 100 / V;
  8.  
  9. int p1Percent = (int)(P1 * H / filled * 100);
  10. int p2Percent = (int)(P2 * H / filled * 100);
  11.  
  12. if (percentFilled <= 100)
  13. {
  14.     Console.WriteLine($"The pool is {percentFilled}% full. Pipe 1: {p1Percent}%. Pipe 2: {p2Percent}%");
  15. }
  16. else
  17. {
  18.     Console.WriteLine($"For {H} hours the pool overflows with {(P1 + P2)*H - V} liters.");
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement