Advertisement
ElviraPetkova

Own Business

Dec 1st, 2018
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.30 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 _4.Own_Bussiness
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int widthFreePlace = int.Parse(Console.ReadLine());
  14.             int lenghtFreePlace = int.Parse(Console.ReadLine());
  15.             int heightFreePlace = int.Parse(Console.ReadLine());
  16.  
  17.             string command = string.Empty;
  18.             double areaFreePlace = 0;
  19.             double areaBox = 0;
  20.  
  21.             while((command = Console.ReadLine()) != "Done")
  22.             {
  23.                 areaFreePlace = widthFreePlace * lenghtFreePlace * heightFreePlace;
  24.                 int numberBox = int.Parse(command);
  25.                 areaBox += numberBox;
  26.  
  27.                 if(areaFreePlace < areaBox && command != "Done")
  28.                 {
  29.                     break;
  30.                 }
  31.             }
  32.             if(areaFreePlace > 0 && command == "Done")
  33.             {
  34.                 Console.WriteLine($"{areaFreePlace - areaBox} Cubic meters left.");
  35.             }
  36.             else
  37.             {
  38.                 Console.WriteLine($"No more free space! You need {Math.Abs(areaFreePlace - areaBox)} Cubic meters more.");
  39.             }
  40.            
  41.         }
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement