Advertisement
rado8506

Задача 02 - Тръби в басейн

Jan 22nd, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 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 ConsoleApp10
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int Vol = int.Parse(Console.ReadLine());
  14.             int P1 = int.Parse(Console.ReadLine());
  15.             int P2 = int.Parse(Console.ReadLine());
  16.             double H = double.Parse(Console.ReadLine());
  17.  
  18.             double P1water = H * P1;
  19.             double P2water = H * P2;
  20.             double TotalWater = P1water + P2water;
  21.             double WaterPerc = TotalWater / Vol * 100;
  22.             double P1Per = P1water / TotalWater * 100;
  23.             double P2Perc = P2water / TotalWater * 100;
  24.  
  25.             if (TotalWater <= Vol)
  26.             {
  27.                 Console.WriteLine("The pool is {0}% full. Pipe 1: {1}%. Pipe 2: {2}%.", Math.Truncate(WaterPerc), Math.Truncate(P1Per),
  28.                     Math.Truncate(P2Perc));
  29.             }
  30.             else if (TotalWater > Vol)
  31.             {
  32.                 Console.WriteLine("For {0} hours the pool overflows with {1} liters.", H, ($"{TotalWater - Vol:f1}"));
  33.             }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement