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