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