Helena12

Own Bussiness

Nov 28th, 2018
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.98 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P04AOwnBussiness {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int shirina = Integer.parseInt(scanner.nextLine());
  8.         int daljina = Integer.parseInt(scanner.nextLine());
  9.         int visochina = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int obemStaq = shirina * daljina * visochina;
  12.         String command = scanner.nextLine();
  13.  
  14.         while (!command.equalsIgnoreCase("done")) {
  15.             int computerNumber = Integer.parseInt(command);
  16.             obemStaq -= computerNumber;
  17.  
  18.             if (obemStaq < 0) {
  19.                 System.out.printf("No more free space! You need %d Cubic meters more.",
  20.                         Math.abs(obemStaq)); break;
  21.             }
  22.             command = scanner.nextLine();
  23.  
  24.             if (command.equalsIgnoreCase("done")) {
  25.                 System.out.printf("%d Cubic meters left.", obemStaq);
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment