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());
- int freeSpace = width * length * height;
- String input = "";
- while (freeSpace > 0) {
- input = scanner.nextLine();
- if (input.equals("Done")) {
- break;
- }
- freeSpace -= Integer.parseInt(input);
- }
- if (input.equals("Done")) {
- System.out.printf("%d Cubic meters left.\n", 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