simonradev

Pipes

Sep 28th, 2016
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2.  
  3. namespace practive
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             int vol = int.Parse(Console.ReadLine());
  10.             int p1 = int.Parse(Console.ReadLine());
  11.             int p2 = int.Parse(Console.ReadLine());        
  12.             double hours = double.Parse(Console.ReadLine());
  13.            
  14.             double volUsed = (hours * (p1 + p2));
  15.             double percentFull  = (volUsed / vol * 100);
  16.             double percentP1 = Math.Truncate((p1 * hours / volUsed) * 100);
  17.             double percentP2 = Math.Truncate((p2 * hours / volUsed) * 100);
  18.            
  19.             if (vol >= volUsed)
  20.             {
  21.                 Console.WriteLine("The pool is {0}% full. Pipe 1: {1}%. Pipe 2: {2}%.", percentFull, percentP1, percentP2);
  22.             }
  23.             else
  24.             {
  25.                 Console.WriteLine("For {0} hours the pool overflows with {1} liters.", hours, (volUsed - vol));
  26.             }
  27.            
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment