Advertisement
Guest User

Untitled

a guest
May 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  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.  
  7.         int a = Integer.parseInt(scanner.nextLine());
  8.         int b = Integer.parseInt(scanner.nextLine());
  9.         int h = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int freeSpace = a * b * h;
  12.         String command = scanner.nextLine();
  13.  
  14.  
  15.  
  16.         if (!command.equals("Done")) {
  17.             for (int i = 0; i < 9999; i++) {
  18.                 freeSpace -= Integer.parseInt(command);
  19.  
  20.                 if (freeSpace <= 0) {
  21.                     System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs(freeSpace));
  22.                     break;
  23.                 }
  24.                     command = scanner.nextLine();
  25.                 }
  26.  
  27.             }else {
  28.             System.out.printf("%d Cubic meters left.", freeSpace);
  29.  
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement