Advertisement
Guest User

Autonomy

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