GerganaTsirkova

TubesInPool

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