Advertisement
Dido09

Moving

Oct 7th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Moving {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int width =Integer.parseInt(scanner.nextLine());
  8. int length =Integer.parseInt(scanner.nextLine());
  9. int height =Integer.parseInt(scanner.nextLine());
  10.  
  11. int value = width * length * height;
  12. int totalBoxValue = 0;
  13.  
  14. String input = scanner.nextLine();
  15. while (!input.equals("Done")){
  16. int currentValue = Integer.parseInt(input);
  17.  
  18.  
  19. totalBoxValue += currentValue;
  20. if (totalBoxValue > value){
  21. System.out.printf("No more free space! You need %d Cubic meters more.",totalBoxValue - value);
  22. break;
  23. }
  24.  
  25. input = scanner.nextLine();
  26. }
  27. if (value - totalBoxValue >= 0) {
  28.  
  29.  
  30. System.out.printf("%d Cubic meters left.", value - totalBoxValue);
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement