Advertisement
Guest User

Untitled

a guest
Sep 26th, 2020
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01.PipesInPool
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int v = int.Parse(Console.ReadLine());
  10.             int p1 = int.Parse(Console.ReadLine());
  11.             int p2 = int.Parse(Console.ReadLine());
  12.             double h = double.Parse(Console.ReadLine());
  13.  
  14.             double p1Lit = p1 * h;
  15.             double p2Lit = p2 * h;
  16.             double totalWater = p1Lit + p2Lit;
  17.  
  18.             double fullPoolPercentage = (totalWater * 100) / v;
  19.             double p1Percentage = (p1Lit * 100) / totalWater;
  20.             double p2Percentage = (p2Lit * 100) / totalWater;
  21.  
  22.             if (v >= totalWater)
  23.  
  24.             {
  25.                 Console.WriteLine($"The pool is {fullPoolPercentage}% full. Pipe 1: {p1Percentage}%. Pipe 2: {p2Percentage}%.");
  26.             }            
  27.            
  28.             else
  29.  
  30.             {
  31.                 double overflows = totalWater - v;
  32.                 Console.WriteLine($"For {h} hours the pool overflows with {overflows} liters.");
  33.             }
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement