galinyotsev123

ProgBasicsExam11and12August2018-E04ownBussiness

Jan 6th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class E04ownBussiness {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int roomWidth = Integer.parseInt(scanner.nextLine());
  8. int roomLength = Integer.parseInt(scanner.nextLine());
  9. int roomHeight = Integer.parseInt(scanner.nextLine());
  10.  
  11. int roomVolume = roomWidth * roomLength * roomHeight;
  12.  
  13. int usedSpace = 0;
  14.  
  15.  
  16. while (true) {
  17. String command = scanner.nextLine();
  18. if (command.equals("Done")) {
  19. break;
  20. }
  21. usedSpace += Integer.parseInt(command);
  22. if (usedSpace >= roomVolume){
  23.  
  24. break;
  25.  
  26. }
  27. }
  28.  
  29.  
  30. if (usedSpace <= roomVolume)
  31. {
  32. System.out.printf("%d Cubic meters left.", roomVolume-usedSpace);
  33. }
  34. else
  35. {
  36. System.out.printf("No more free space! You need %d Cubic meters more.",usedSpace - roomVolume);
  37. }
  38.  
  39. }
  40.  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment