Advertisement
TodorovP

Pipes_in_the_pool

Jan 22nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 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 Pipes_in_the_pool
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var maxVolume = int.Parse(Console.ReadLine());
  14.             var p1 = int.Parse(Console.ReadLine());
  15.             var p2 = int.Parse(Console.ReadLine());
  16.             var hours = double.Parse(Console.ReadLine());
  17.  
  18.  
  19.             double volumeP1 = p1 * hours;
  20.             double volumeP2 = p2 * hours;
  21.             double volumeTotal = volumeP1 + volumeP2;
  22.             double overflow = volumeTotal - maxVolume;
  23.  
  24.             double percentP1 = Math.Floor(volumeP1 / volumeTotal * 100);
  25.             double percentP2 = Math.Floor(volumeP2 / volumeTotal * 100);
  26.             double percentTotal = Math.Floor(volumeTotal / maxVolume * 100);
  27.  
  28.  
  29.             if (volumeTotal <= maxVolume)
  30.             {
  31.                 Console.WriteLine($"The pool is {percentTotal}% full. " +
  32.                     $"Pipe 1: {percentP1}%. Pipe 2: {percentP2}%.");
  33.             }
  34.             else
  35.             {
  36.                 Console.WriteLine($"For {hours} hours the pool overflows " +
  37.                     $"with {overflow:f1} liters.");
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement