Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Module: 08. While-Loop - Lab
- Task: 09. Moving
- Start time: 22:32
- Finish time: 19:21
- Date: 7 October 2018
- Creator: Don Savage
- */
- import java.util.Scanner;
- public class Moving {
- public static void main(String[] args) {
- Scanner Scan_Moving = new Scanner(System.in);
- int W = Integer.parseInt(Scan_Moving.nextLine());
- int L = Integer.parseInt(Scan_Moving.nextLine());
- int H = Integer.parseInt(Scan_Moving.nextLine());
- int Total = W * L * H;
- boolean BL = true;
- String SI = Scan_Moving.nextLine();
- while (!SI.equals("Done")) {
- int B = Integer.parseInt(SI);
- Total -= B;
- if (Total < 0) {
- BL = false;
- break;
- }
- SI = Scan_Moving.nextLine();
- }
- if (BL)
- System.out.printf("%d Cubic meters left.", Total);
- else
- System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs((Total)));
- }
- }
- /*
- --- Var Legend
- W = Width
- L = Length
- H = Height
- B = Box
- SI = String input
- BL = Boolean var
- Total = Sum Result
- */
Add Comment
Please, Sign In to add comment