Untitled

 avatar
unknown
java
4 years ago
1.1 kB
5
Indexable
package WhileLoops;

import java.util.Scanner;

public class Moving {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int widthSpace = Integer.parseInt(scan.nextLine());
        int lengthSpace = Integer.parseInt(scan.nextLine());
        int heightSpace = Integer.parseInt(scan.nextLine());

        double spaceSum = widthSpace * lengthSpace * heightSpace;

        int addition = 0;


        String input = scan.nextLine();
        while (!input.equals("Done")) {
            int number = Integer.parseInt(input);

            addition = number + addition;

            if (spaceSum < addition) {
                double diff = Math.abs(addition - spaceSum);
                System.out.printf("No more free space! You need %.0f Cubic meters more.", diff);
                break;
            }

            input = scan.nextLine(); //puska sledvasht cikal na loopa
        }
        if (input.equals("Done")) {
            double diff = Math.abs(addition - spaceSum);
            System.out.printf("%.0f Cubic meters left.", diff);

        }
    }
}
Editor is loading...