aneliabogeva

Moving

Dec 13th, 2020
716
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         Integer width = Integer.parseInt(scanner.nextLine());
  7.         Integer length = Integer.parseInt(scanner.nextLine());
  8.         Integer height = Integer.parseInt(scanner.nextLine());
  9.         String numberOfBoxes = scanner.nextLine();
  10.         Integer volume = width*length* height.intValue();
  11.         Integer currentVolume = 0;
  12.  
  13.         while(!"Done".equals(numberOfBoxes)){
  14.             currentVolume = currentVolume + Integer.parseInt(numberOfBoxes);
  15.             if(currentVolume > volume){
  16.                 Integer diff = Math.abs(currentVolume-volume);
  17.                 System.out.printf("No more free space! You need %d Cubic meters more.",diff);
  18.                 break;
  19.             }else{}
  20.             numberOfBoxes = scanner.nextLine();
  21.         }
  22.         if(currentVolume <= volume){
  23.             Integer diff = Math.abs(currentVolume-volume);
  24.             System.out.printf("%d Cubic meters left.",diff);
  25.         }
  26.     }
  27. }
  28.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×