Advertisement
Kancho

Removal_Wrong

Feb 7th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. Scanner keyboard = new Scanner(System.in);
  2. System.out.print("Width: ");
  3. int w = Integer.parseInt(keyboard.nextLine());
  4. System.out.print("Height: ");
  5. int h = Integer.parseInt(keyboard.nextLine());
  6. System.out.print("Depth: ");
  7. int d = Integer.parseInt(keyboard.nextLine());
  8. int roomVolume = w * h * d;
  9. System.out.println("Room volume is " + roomVolume);
  10. String input = keyboard.nextLine();
  11. int boxes = Integer.parseInt(input);
  12. while (!input.equalsIgnoreCase("Done")) {
  13. boxes = Integer.parseInt(input);
  14. roomVolume = roomVolume - boxes;
  15. if (roomVolume <= 0) {
  16. break;
  17. }
  18. boxes = boxes + boxes;
  19. input = keyboard.nextLine();
  20. }
  21.  
  22. if (roomVolume <= 0) {
  23. System.out.printf("You have %d cubic meters left.", (roomVolume));
  24. } else {
  25. System.out.printf("You have %d cubic meters left and carried %d boxes", roomVolume, boxes);
  26. }
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement