Advertisement
Guest User

Untitled

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