Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 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 _02.PoolPipes
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var VPool = int.Parse(Console.ReadLine());
  14.             var p1For1Hour = int.Parse(Console.ReadLine());
  15.             var p2For1Hour = int.Parse(Console.ReadLine());
  16.             var missingHours = double.Parse(Console.ReadLine());
  17.  
  18.             var totalFirstPipe = p1For1Hour * missingHours;
  19.             var totalSecondPipe = p2For1Hour * missingHours;
  20.             var totalPipeLiters = totalFirstPipe + totalSecondPipe;
  21.  
  22.             if (VPool>= totalPipeLiters)
  23.             {
  24.                 var percentagePoolFill = (totalPipeLiters / VPool) * 100;
  25.                 var percentageFirstPipe = (totalFirstPipe / totalPipeLiters) * 100;
  26.                 var percentageSecondPipe = (totalSecondPipe / totalPipeLiters) * 100;
  27.  
  28.                 Console.WriteLine("The pool is {0}% full. Pipe 1: {1}%. Pipe 2: {2}%.",
  29.                    Math.Truncate(percentagePoolFill), Math.Truncate(percentageFirstPipe), Math.Truncate(percentageSecondPipe/1));
  30.             }
  31.             else
  32.             {
  33.                 var overflowing = totalPipeLiters - VPool;
  34.                 Console.WriteLine("For {0} hours the pool overflows with {1} liters.",
  35.                     missingHours, overflowing);
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement