Guest User

Problem 2 - Pool Pipes

a guest
Sep 16th, 2016
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace p02_Pool_pipes
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int volume = int.Parse(Console.ReadLine());
  10.             int flowP1 = int.Parse(Console.ReadLine());
  11.             int flowP2 = int.Parse(Console.ReadLine());
  12.             double hours = double.Parse(Console.ReadLine());
  13.  
  14.             double volP1 = hours * flowP1;
  15.             double volP2 = hours * flowP2;
  16.  
  17.             double poolFilled = volP1 + volP2;
  18.  
  19.             if (poolFilled <= volume) // particulary filled
  20.             {
  21.                 Console.WriteLine("The pool is {0}% full. Pipe 1: {1}%. Pipe 2: {2}%.", Math.Floor(poolFilled/volume*100),
  22.                                                                                         Math.Floor(volP1/poolFilled*100),
  23.                                                                                         Math.Floor(volP2 / poolFilled * 100));
  24.             }
  25.             else // over filled
  26.             {
  27.                 Console.WriteLine("For {0} hours the pool overflows with {1} liters.", hours, (poolFilled-volume));
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment