Advertisement
kzborisov

Untitled

Oct 28th, 2018
797
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 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.Moving
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. //1. Read Input
  14. int freeSpaceWidth = int.Parse(Console.ReadLine());
  15. int freeSpaceLength = int.Parse(Console.ReadLine());
  16. int freeSpaceHeight = int.Parse(Console.ReadLine());
  17. string command = Console.ReadLine();
  18.  
  19. //2. Manipulate Data
  20. int roomVolume = freeSpaceWidth * freeSpaceLength * freeSpaceHeight;
  21. bool isThereEnoughSpace = true;
  22.  
  23. while (command != "Done")
  24. {
  25. //1.2 Read Input
  26. int boxes = int.Parse(command);
  27.  
  28. //2.2 Manipulate Data
  29. roomVolume -= boxes;
  30.  
  31. if (roomVolume < 0 )
  32. {
  33. isThereEnoughSpace = false;
  34. break;
  35. }
  36.  
  37. command = Console.ReadLine();
  38. }
  39.  
  40. //3. Print Result
  41.  
  42. if (isThereEnoughSpace)
  43. {
  44. Console.WriteLine($"{roomVolume} Cubic meters left.");
  45. }
  46. else
  47. {
  48. Console.WriteLine($"No more free space! You need {Math.Abs(roomVolume)} Cubic meters more.");
  49. }
  50.  
  51. }
  52. }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement