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 w = Integer.parseInt(scanner.nextLine());
- int l = Integer.parseInt(scanner.nextLine());
- int h = Integer.parseInt(scanner.nextLine());
- int freeSpace = w * l * h;
- String input = scanner.nextLine();
- boolean isThereEnoughSpace = true;
- while (!input.equals("Done")) {
- int boxes = Integer.parseInt(input);
- freeSpace = freeSpace - boxes;
- if (freeSpace < 0) {
- isThereEnoughSpace = false;
- break;
- }
- input = scanner.nextLine(); //?????
- }
- if (isThereEnoughSpace) {
- System.out.printf("%d Cubic meters left.", freeSpace);
- } else {
- System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs(freeSpace));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement