limonchesled

07. Moving

Feb 7th, 2024
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. int length = int.Parse(Console.ReadLine());
  2. int width = int.Parse(Console.ReadLine());
  3. int hight = int.Parse(Console.ReadLine());
  4. int totalVolume = length * width * hight;
  5.  
  6. while (totalVolume >= 0)
  7. {
  8. string input = Console.ReadLine();
  9.  
  10. if (input == "Done")
  11. {
  12. break;
  13. }
  14. else
  15. {
  16. int currentNumberOfCartons = int.Parse(input);
  17. totalVolume -= currentNumberOfCartons;
  18. }
  19. }
  20. if (totalVolume > 0)
  21. {
  22. Console.WriteLine($"{totalVolume} Cubic meters left.");
  23. }
  24. else
  25. {
  26. Console.WriteLine($"No more free space! You need {Math.Abs(totalVolume)} Cubic meters more.");
  27. }
Advertisement
Add Comment
Please, Sign In to add comment