DidiMilikina

Тръби в басейн

Mar 25th, 2017
36
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 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 Тръби_в_басейн
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var volumeInLiters = int.Parse(Console.ReadLine());
  14.             var debitFirstPipe = int.Parse(Console.ReadLine());
  15.             var debitSecondPipe = int.Parse(Console.ReadLine());
  16.             var hours = double.Parse(Console.ReadLine());
  17.             var totalDebitFirstPipe = hours * debitFirstPipe;
  18.             var totalDebitSecondPipe = hours * debitSecondPipe;
  19.             var totalDebit = totalDebitFirstPipe + totalDebitSecondPipe;
  20.             if (totalDebit > volumeInLiters)
  21.             {
  22.  
  23.                 Console.WriteLine($"For {hours} hours the pool overflows with {totalDebit - volumeInLiters} liters.");
  24.             }
  25.             else
  26.             {
  27.                 var percent = Math.Floor(totalDebit / volumeInLiters * 100) ;
  28.                 var percentFirstPipe = Math.Floor(totalDebitFirstPipe / totalDebit * 100) ;
  29.                 var percentSecondPipe = Math.Floor(totalDebitSecondPipe / totalDebit * 100);
  30.  
  31.                 Console.WriteLine($"The pool is {percent}% full. Pipe 1: {percentFirstPipe}%. Pipe 2: {percentSecondPipe}%.");
  32.  
  33.             }
  34.  
  35.  
  36.  
  37.  
  38.  
  39.         }
  40.     }
  41. }
Add Comment
Please, Sign In to add comment