anizko

08. Moving

Apr 4th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Moving
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             double w = double.Parse(Console.ReadLine());
  11.             double l = double.Parse(Console.ReadLine());
  12.             double h = double.Parse(Console.ReadLine());
  13.  
  14.             double AllSpace = w * l * h;
  15.  
  16.             string Box = Console.ReadLine();
  17.             double MoveBoxes = 0;
  18.          
  19.  
  20.             while (MoveBoxes < AllSpace)
  21.             {
  22.                 if (Box != "Done")
  23.                 {
  24.                     double Boxes = double.Parse(Box);
  25.                     Box = Console.ReadLine();
  26.                     MoveBoxes += Boxes;
  27.                 }
  28.                 else
  29.                 {
  30.                     break;
  31.                 }
  32.             }
  33.  
  34.             double FreeSpace = Math.Abs(MoveBoxes - AllSpace);
  35.  
  36.             if (Box == "Done" && MoveBoxes < AllSpace)
  37.             {
  38.                 Console.WriteLine($"{FreeSpace} Cubic meters left.");
  39.             }
  40.             else if (MoveBoxes > AllSpace)
  41.             {
  42.                 Console.WriteLine($"No more free space! You need {FreeSpace} Cubic meters more.");
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment