Advertisement
Andreeva-Magdalena97

OwnBussines

Mar 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.89 KB | None | 0 0
  1. package WhileLoop;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class OwnBussines {
  6.     public static void main(String[] args) {
  7.         Scanner s = new Scanner(System.in);
  8.         int widht = Integer.parseInt(s.nextLine());
  9.         int lenght = Integer.parseInt(s.nextLine());
  10.         int height = Integer.parseInt(s.nextLine());
  11.         int count = 0;
  12.         int kubMet = widht * lenght * height;
  13.         String name = s.nextLine();
  14.         while(!name.equals("Done")){
  15.  
  16.             int number = Integer.parseInt(name);
  17.  
  18.             count +=number;
  19.             if(kubMet <= count){
  20.                 System.out.printf("No more free space! You need %d Cubic meters more.", Math.abs(count-kubMet));
  21.                 break;
  22.             }
  23.             name = s.nextLine();
  24.         }
  25.  
  26.         if (kubMet > count){
  27.             System.out.printf("%d Cubic meters left.", kubMet - count);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement