Dianov

While Loop - Lab (09. Moving (not included in final score))

Dec 29th, 2020
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 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 width = int.Parse(Console.ReadLine());
  14.             int length = int.Parse(Console.ReadLine());
  15.             int hight = int.Parse(Console.ReadLine());
  16.             int volume = width * length * hight;
  17.             int boxVolume = 0;
  18.  
  19.             string boxes = Console.ReadLine();
  20.  
  21.             while (boxes != "Done")
  22.             {
  23.                 boxVolume += int.Parse(boxes);
  24.                 if (boxVolume >= volume)
  25.                 {
  26.                     int neededspace = boxVolume - volume;
  27.                     Console.WriteLine($"No more free space! You need {neededspace} Cubic meters more.");
  28.                     break;
  29.                 }
  30.                 boxes = Console.ReadLine();
  31.             }
  32.             if (boxes == "Done")
  33.             {
  34.                 int volumeleft = volume - boxVolume;
  35.                 Console.WriteLine($"{volumeleft} Cubic meters left.");
  36.             }
  37.         }
  38.     }  
  39. }
Advertisement
Add Comment
Please, Sign In to add comment