Advertisement
pjordanov

08. Moving - While Loop

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