Lyubohd

Moving

Mar 6th, 2021
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         int width = Integer.parseInt(scan.nextLine());
  7.         int length = Integer.parseInt(scan.nextLine());
  8.         int height = Integer.parseInt(scan.nextLine());
  9.  
  10.         int volume = (width * length) * height;
  11.         String input = scan.nextLine();
  12.         while (!input.equals("Done")) {
  13.             int boxes = Integer.parseInt(input);
  14.             volume -= boxes;
  15.             if (volume < 0) {
  16.                 break;
  17.             }
  18.  
  19.             input = scan.nextLine();
  20.         }
  21.  
  22.         if (volume < 0) {
  23.             System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs(volume));
  24.         } else {
  25.             System.out.printf("%d Cubic meters left.", volume);
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment