Advertisement
Sim0o0na

Untitled

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