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 roomVolume = w * l * h;
- int boxesVolume = 0;
- while (boxesVolume <= roomVolume) {
- String command = scanner.nextLine();
- if(command.equalsIgnoreCase("done")) {
- break;
- }
- int currentBoxesCount = Integer.parseInt(command);
- boxesVolume += currentBoxesCount;
- }
- int volumeDifference = roomVolume - boxesVolume;
- if (volumeDifference >= 0) {
- System.out.printf("%d Cubic meters left.", volumeDifference);
- } else {
- System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs(volumeDifference));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment