Advertisement
svephoto

Moving [C#]

Apr 1st, 2021
1,776
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Moving
  4. {
  5.     public class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             int width = int.Parse(Console.ReadLine());
  10.             int legth = int.Parse(Console.ReadLine());
  11.             int height = int.Parse(Console.ReadLine());
  12.             double freeSpace = width * legth * height;
  13.             string input = Console.ReadLine();
  14.            
  15.             while (input != "Done")
  16.             {
  17.                 double currentBoxes = double.Parse(input);
  18.  
  19.                 freeSpace = freeSpace - currentBoxes;
  20.  
  21.                
  22.                 if (freeSpace < 0)
  23.                 {                    
  24.                     Console.WriteLine("No more free space! You need " + Math.Abs(freeSpace) + " Cubic meters more.");
  25.                     return;
  26.                 }
  27.                
  28.                 input = Console.ReadLine();
  29.             }
  30.                          
  31.             Console.WriteLine(freeSpace + " Cubic meters left.");          
  32.         }
  33.     }
  34. }
  35.  
  36.  
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement