dextercane

Moving - 4

Jul 25th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 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 Moving
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int width = int.Parse(Console.ReadLine());
  14.             int length = int.Parse(Console.ReadLine());
  15.             int height = int.Parse(Console.ReadLine());
  16.  
  17.             string command = Console.ReadLine();
  18.             int volume = width * length * height;
  19.             int spaceTaken = 0;
  20.  
  21.             while (command != "Done")
  22.             {
  23.                 int boxes = int.Parse(command);
  24.                 spaceTaken += boxes;
  25.  
  26.                 if (spaceTaken > volume)
  27.                 {
  28.                     int spaceNeeded = spaceTaken - volume;
  29.                     Console.WriteLine($"No more free space! You need {spaceNeeded} Cubic meters more.");
  30.                     break;
  31.                 }
  32.  
  33.                 command = Console.ReadLine();
  34.             }
  35.  
  36.             if (spaceTaken <= volume)
  37.             {
  38.             int spaceLeft = volume - spaceTaken;
  39.             Console.WriteLine($"{spaceLeft} Cubic meters left.");
  40.             }
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment