nvnnaidenov

PipesInPool - Chapter 3.1

Feb 11th, 2022
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. //Task 002, Chapter 3.1
  2. using System;
  3.  
  4. public class PipesInPool
  5. {
  6.     static void Main()
  7.     {
  8.         int volume = int.Parse(Console.ReadLine());
  9.         int firstPipe = int.Parse(Console.ReadLine());
  10.         int secondPipe = int.Parse(Console.ReadLine());
  11.         double hours = double.Parse(Console.ReadLine());
  12.  
  13.         double water = (firstPipe + secondPipe) * hours;
  14.  
  15.         if(water < volume)
  16.         {
  17.             Console.WriteLine($"The pool is {Math.Truncate(water / volume * 100)}% full. " +
  18.                 $"Pipe 1: {Math.Truncate(firstPipe * hours / water * 100)}%. " +
  19.                 $"Pipe 2: {Math.Truncate(secondPipe * hours / water * 100)}%.");
  20.         }
  21.         else
  22.         {
  23.             Console.WriteLine($"For {hours} hours the pool overflows with {water - volume} liters.");
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment