donsavage

Moving

Oct 29th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.15 KB | None | 0 0
  1. /*
  2.  
  3. Module: 08. While-Loop - Lab
  4. Task: 09. Moving
  5. Start time: 22:32
  6. Finish time: 19:21
  7. Date: 7 October 2018
  8. Creator: Don Savage
  9.  
  10. */
  11.  
  12. import java.util.Scanner;
  13.  
  14. public class Moving {
  15.     public static void main(String[] args) {
  16.         Scanner Scan_Moving = new Scanner(System.in);
  17.  
  18.         int W = Integer.parseInt(Scan_Moving.nextLine());
  19.         int L = Integer.parseInt(Scan_Moving.nextLine());
  20.         int H = Integer.parseInt(Scan_Moving.nextLine());
  21.  
  22.         int Total = W * L * H;
  23.         boolean BL = true;
  24.  
  25.         String SI = Scan_Moving.nextLine();
  26.         while (!SI.equals("Done")) {
  27.             int B = Integer.parseInt(SI);
  28.             Total -= B;
  29.             if (Total < 0) {
  30.                 BL = false;
  31.                 break;
  32.             }
  33.             SI = Scan_Moving.nextLine();
  34.         }
  35.         if (BL)
  36.             System.out.printf("%d Cubic meters left.", Total);
  37.         else
  38.             System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs((Total)));
  39.     }
  40. }
  41.  
  42. /*
  43. --- Var Legend
  44.  
  45. W = Width
  46. L = Length
  47. H = Height
  48. B = Box
  49. SI = String input
  50. BL = Boolean var
  51. Total = Sum Result
  52.  
  53. */
Add Comment
Please, Sign In to add comment