Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Moving {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int width = Integer.parseInt(scanner.nextLine());
- int length = Integer.parseInt(scanner.nextLine());
- int height = Integer.parseInt(scanner.nextLine());
- String input = scanner.nextLine();
- int houseArea = width * length * height;
- while (true) {
- if ("Done".equals(input)) {
- break;
- }
- int boxes = Integer.parseInt(input);
- houseArea -= boxes;
- if (houseArea < 0) {
- System.out.printf("No more free space! You need %d Cubic meters more.%n", Math.abs(houseArea));
- break;
- }
- input = scanner.nextLine();
- }
- if (houseArea >= 0) {
- System.out.printf("%d Cubic meters left.", houseArea);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement