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