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