simonradev

PipesInThePool

Feb 11th, 2017
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace LiveDemo2
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //           •    Първият ред съдържа числото V – Обем на басейна в литри – цяло число в интервала[1…10000].
  14.             //•   Вторият ред съдържа числото P1 – дебит на първата тръба за час – цяло число в интервала[1…5000].
  15.             //•   Третият ред съдържа числото P2 – дебит на втората тръба за час– цяло число в интервала[1…5000].
  16.             //•   Четвъртият ред съдържа числото H – часовете които работникът отсъства – число с плаваща запетая в интервала[1.0…24.00]
  17.  
  18.             int poolVolume = int.Parse(Console.ReadLine());
  19.             int firstPump = int.Parse(Console.ReadLine());
  20.             int secondPump = int.Parse(Console.ReadLine());
  21.             double hoursWorkerIsNotArount = double.Parse(Console.ReadLine());
  22.  
  23.             double firstPumpPumped = firstPump * hoursWorkerIsNotArount;
  24.             double secondPumpPumped = secondPump * hoursWorkerIsNotArount;
  25.  
  26.             double twoPumpsPumped = firstPumpPumped + secondPumpPumped;
  27.             if (twoPumpsPumped <= poolVolume)
  28.             {
  29.                 int poolPercentFul = (int)(twoPumpsPumped / poolVolume * 100);
  30.                 int firstPipePercent = (int)(firstPumpPumped / twoPumpsPumped * 100);
  31.                 int secondPipePercent = (int)(secondPumpPumped / twoPumpsPumped * 100);
  32.  
  33.                 Console.WriteLine($"The pool is {poolPercentFul}% full. Pipe 1: {firstPipePercent}%. Pipe 2: {secondPipePercent}%.");
  34.             }
  35.             else
  36.             {
  37.                 double litersOverflow = Math.Abs(poolVolume - twoPumpsPumped);
  38.  
  39.  
  40.                 Console.WriteLine($"For {hoursWorkerIsNotArount} hours the pool overflows with {litersOverflow} liters.");
  41.             }
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment