deyanivanov966

09. Moving

Apr 1st, 2021
206
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. public class Moving {
  3.     public static void main(String[] args) {
  4.         Scanner scanner = new Scanner(System.in);
  5.         int w = Integer.parseInt(scanner.nextLine());
  6.         int l = Integer.parseInt(scanner.nextLine());
  7.         int h = Integer.parseInt(scanner.nextLine());
  8.         int volume = w * l * h;
  9.         while (true) {
  10.             String input = scanner.nextLine();
  11.             if (input.equals("Done")) {
  12.                 System.out.println(volume + " Cubic meters left.");
  13.                 break;
  14.             }
  15.             int box = Integer.parseInt(input);
  16.             volume -= box;
  17.             if (volume < 0) {
  18.                 System.out.printf(
  19.                         "No more free space! You need %d Cubic meters more.",
  20.                         Math.abs(volume));
  21.                 break;
  22.             }
  23.         }
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment