dosseva

FUND_07.Water Overflow

Mar 6th, 2021 (edited)
1,077
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.74 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _07_Water_Overflow
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int waterTankLitres = 255;
  10.             int numLitres = int.Parse(Console.ReadLine());
  11.  
  12.             int sumLitres = 0;
  13.  
  14.             for (int i = 1; i <= numLitres; i++)
  15.             {
  16.                 int litres = int.Parse(Console.ReadLine());
  17.                 if (litres <= (waterTankLitres - sumLitres) && litres <= 255)
  18.                 {
  19.                     sumLitres += litres;
  20.                 }
  21.                 else
  22.                 {
  23.                     Console.WriteLine("Insufficient capacity!");
  24.                 }
  25.  
  26.             }
  27.  
  28.             Console.WriteLine(sumLitres);
  29.         }
  30.     }
  31. }
  32.  
Add Comment
Please, Sign In to add comment