Advertisement
Guest User

Untitled

a guest
Apr 29th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 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 pipesInPool
  8. {
  9.     class pipesInPool
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var volumePool = double.Parse(Console.ReadLine());
  14.             var debitPipe1 = double.Parse(Console.ReadLine());
  15.             var debitPipe2 = double.Parse(Console.ReadLine());
  16.             var hours = double.Parse(Console.ReadLine());
  17.  
  18.            
  19.             var pulnotaPool = (debitPipe1 + debitPipe2)*hours;
  20.             var pulnotaPoolProzent = pulnotaPool/volumePool*100;
  21.             var prinosPipe1 = Math.Truncate((debitPipe1 / (debitPipe1+debitPipe2))*100); //Тук вместо Math.Round използваме Math.Truncate
  22.             var prinosPipe2 = Math.Truncate((debitPipe2 / (debitPipe1 + debitPipe2))*100); //Тук вместо Math.Round използваме Math.Truncate
  23.  
  24.             if (pulnotaPool <= volumePool)
  25.             {
  26.                 Console.WriteLine( "The pool is {0}% full." +
  27.                     " Pipe 1: {1}%. Pipe 2: {2}%.", (int)pulnotaPoolProzent, (int)prinosPipe1, (int)prinosPipe2); // Тук си кастваме по едно (int) отпред.
  28.             }
  29.  
  30.             else if (pulnotaPool > volumePool)
  31.             {
  32.                 var overflowsL = pulnotaPool - volumePool;
  33.                 Console.WriteLine("For {0} hours the pool overflows with {1} liters."
  34.                                     ,hours, overflowsL);
  35.             }
  36.         }
  37.     }
  38.  
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement