Advertisement
Spocoman

07. Moving

Aug 29th, 2024 (edited)
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.87 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.         int width = Integer.parseInt(scanner.nextLine());
  7.         int length = Integer.parseInt(scanner.nextLine());
  8.         int height = Integer.parseInt(scanner.nextLine());
  9.        
  10.         int freeSpace = width * length * height;
  11.  
  12.         String input = "";
  13.         while (freeSpace > 0) {
  14.             input = scanner.nextLine();
  15.             if (input.equals("Done")) {
  16.                 break;
  17.             }
  18.             freeSpace -= Integer.parseInt(input);
  19.         }
  20.  
  21.         if (input.equals("Done")) {
  22.             System.out.printf("%d Cubic meters left.\n", freeSpace);
  23.         } else {
  24.             System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs(freeSpace));
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement