Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Demo {
- 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 volumeHouse = width * length * height;
- String input = scanner.nextLine();
- int boxes = 0;
- int sumBoxes = 0;
- while (!input.equals("Done")) {
- boxes = Integer.parseInt(input);
- sumBoxes = sumBoxes + boxes;
- if (sumBoxes >= volumeHouse) {
- break;
- }
- input = scanner.nextLine();
- }
- int diff = Math.abs(volumeHouse - sumBoxes);
- if (sumBoxes < volumeHouse) {
- System.out.printf("%d Cubic meters left.", diff);
- } else {
- System.out.printf("No more free space! You need %d Cubic meters more.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement