Advertisement
Vladimir76

Relocation

Oct 26th, 2020
1,997
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1. using System;
  2.  
  3. namespace bags
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int width = int.Parse(Console.ReadLine());
  10.             int length = int.Parse(Console.ReadLine());
  11.             int height = int.Parse(Console.ReadLine());
  12.  
  13.             int volume = width * length * height;
  14.             int sumVolumeBags = 0;
  15.             int differenceVolume = 0;
  16.  
  17.             while (true)
  18.             {
  19.                 string input = Console.ReadLine();
  20.                 if (input != "Done")
  21.                 {
  22.                     int volumeBags = int.Parse(input);
  23.                     sumVolumeBags += volumeBags;
  24.                     differenceVolume = volume - sumVolumeBags;
  25.  
  26.                     if (differenceVolume < 0)
  27.                     {
  28.                         Console.WriteLine("No more free space! You " +
  29.                             "need {0} Cubic meters more.",
  30.                             Math.Abs(differenceVolume));
  31.                         break;
  32.                     }
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine("{0} Cubic meters left.",
  37.                         differenceVolume);
  38.                     break;
  39.                 }
  40.             }
  41.  
  42.         }
  43.     }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement