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 scan = new Scanner(System.in);
- int weight = Integer.parseInt(scan.nextLine());
- int length = Integer.parseInt(scan.nextLine());
- int height = Integer.parseInt(scan.nextLine());
- int volume = weight * length * height;
- String input = scan.nextLine();
- while (!"Done".equals(input)) {
- int boxes = Integer.parseInt(input);
- volume -= boxes;
- if (volume < 0) {
- System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs(volume));
- break;
- }
- input = scan.nextLine();
- }
- if (volume >= 0) {
- System.out.printf("%d Cubic meters left.", volume);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement