Advertisement
Guest User

Untitled

a guest
Jul 13th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Demoo {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int width = Integer.parseInt(scanner.nextLine());
  8. int length = Integer.parseInt(scanner.nextLine());
  9. int high = Integer.parseInt(scanner.nextLine());
  10. String imput = scanner.nextLine();
  11. int all = width * length * high;
  12. int count = 0;
  13.  
  14. while (!"Done".equals(imput)){
  15. int neededMeters = Integer.parseInt(imput);
  16. count += neededMeters;
  17.  
  18. if (all < count){
  19. int noFreeSpace = Math.abs(count - all);
  20. System.out.println(String.format("No more free space! You need %d Cubic meters more.", noFreeSpace));
  21. }
  22.  
  23. imput = scanner.nextLine();
  24. }
  25. if (imput.equals("Done") && all > count){
  26. int freeSpace = all - count;
  27. System.out.println(String.format("%d Cubic meters left.", freeSpace));
  28. }
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement