Advertisement
Lyubohd

Moving

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