Advertisement
Guest User

pool2

a guest
Jun 18th, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2.  
  3. namespace pipes
  4. {
  5.     class MainClass
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             var litPool = int.Parse(Console.ReadLine());
  10.             var p1 = int.Parse(Console.ReadLine());
  11.             var p2 = int.Parse(Console.ReadLine());
  12.             double hoursMiss = double.Parse(Console.ReadLine());
  13.  
  14.  
  15.             var water = p1 * hoursMiss + p2 * hoursMiss;
  16.  
  17.             if(water <= litPool){
  18.                 var percentOfWater = Math.Truncate (water / litPool * 100);
  19.                 var percentFirtPipe = Math.Truncate (p1 * hoursMiss / water * 100);
  20.                 var secondPipePercent = Math.Truncate (p2 * hoursMiss / water * 100);
  21.                 Console.WriteLine("The pool is {0}% full. Pipe 1: {1}%. Pipe 2: {2}%.",percentOfWater, percentFirtPipe, secondPipePercent);
  22.             }
  23.  
  24.             else{
  25.                 var overflow = water - litPool;
  26.                 Console.WriteLine("For {0:0.0} hours the pool overflows with {1:0.0} liters.", hoursMiss, overflow);
  27.  
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement