Advertisement
AngelKejov

Untitled

Apr 3rd, 2021
71
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Moving {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.  
  10.         int width = Integer.parseInt(sc.nextLine());
  11.         int length = Integer.parseInt(sc.nextLine());
  12.         int height = Integer.parseInt(sc.nextLine());
  13.  
  14.         int kubicMeters = width * length * height;
  15.         int boxesKbMeters = 0;
  16.         while (true) {
  17.             String input = sc.nextLine();
  18.  
  19.             if (!input.equals("Done")) {
  20.                 int numbers = Integer.parseInt(input);
  21.                 boxesKbMeters += numbers;
  22.                 if (boxesKbMeters > kubicMeters) {
  23.                     int diff = Math.abs(boxesKbMeters - kubicMeters);
  24.                     System.out.printf("No more free space!" +
  25.                             " You need %d Cubic meters more.", diff);
  26.                     break;
  27.                 }
  28.             } else {
  29.                 int diff = Math.abs(kubicMeters - boxesKbMeters);
  30.                 System.out.printf("%d Cubic meters left.", diff);
  31.                 break;
  32.             }
  33.  
  34.         }
  35.     }
  36. }
  37.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement