fumanbest

Moving

Oct 13th, 2018
359
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 Moving
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int widthFree = int.Parse(Console.ReadLine());
  14.             int lengthFree = int.Parse(Console.ReadLine());
  15.             int heightFree = int.Parse(Console.ReadLine());
  16.             int freeHouseVolume = widthFree * lengthFree * heightFree;
  17.             int sumCubics = 0;
  18.             string command = Console.ReadLine();
  19.  
  20.             while (command != "Done")
  21.             {
  22.                 int currentCubic = int.Parse(command);
  23.                 sumCubics += currentCubic;
  24.                 if (freeHouseVolume < sumCubics)
  25.                 {
  26.                     int neededCubics = sumCubics - freeHouseVolume;
  27.                     Console.WriteLine($"No more free space! You need {neededCubics} Cubic meters more.");
  28.                     break;
  29.                 }
  30.                 command = Console.ReadLine();
  31.             }
  32.             if (command == "Done")
  33.             {
  34.                 int freeCubics = freeHouseVolume - sumCubics;
  35.                 Console.WriteLine($"{freeCubics} Cubic meters left.");
  36.             }
  37.            
  38.         }
  39.     }
  40. }
Add Comment
Please, Sign In to add comment