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