BapBapuHa

moving

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