Advertisement
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 width =Integer.parseInt(scanner.nextLine());
- int length =Integer.parseInt(scanner.nextLine());
- int height =Integer.parseInt(scanner.nextLine());
- int value = width * length * height;
- int totalBoxValue = 0;
- String input = scanner.nextLine();
- while (!input.equals("Done")){
- int currentValue = Integer.parseInt(input);
- totalBoxValue += currentValue;
- if (totalBoxValue > value){
- System.out.printf("No more free space! You need %d Cubic meters more.",totalBoxValue - value);
- break;
- }
- input = scanner.nextLine();
- }
- if (value - totalBoxValue >= 0) {
- System.out.printf("%d Cubic meters left.", value - totalBoxValue);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement