Advertisement
Threed90

04.Moving

Oct 28th, 2018
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.90 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04.Moving
  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.  
  15.             while (true)
  16.             {
  17.                 string cartons = Console.ReadLine();
  18.                 if(cartons=="Done")
  19.                 {
  20.                     Console.WriteLine($"{Math.Abs(volume)} Cubic meters left.");
  21.                     break;
  22.                 }
  23.  
  24.                 volume -= int.Parse(cartons);
  25.  
  26.                 if(volume<0)
  27.                 {
  28.                     Console.WriteLine($"No more free space! You need {Math.Abs(volume)} Cubic meters more.");
  29.                     break;
  30.                 }
  31.             }
  32.         }
  33.  
  34.  
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement