Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class proben {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int roomWidth = Integer.parseInt(scanner.nextLine());
- int roomLength = Integer.parseInt(scanner.nextLine());
- int roomHeight = Integer.parseInt(scanner.nextLine());
- int roomVolume = roomWidth * roomLength * roomHeight;
- int usedSpace = 0;
- while (true) {
- String command = scanner.nextLine();
- if (command.equals("Done")) {
- break;
- }
- usedSpace += Integer.parseInt(command);
- if (usedSpace >= roomVolume){
- break;
- }
- }
- if (usedSpace <= roomVolume)
- {
- System.out.printf("%d Cubic meters left.", roomVolume-usedSpace);
- }
- else
- {
- System.out.printf("No more free space! You need %d Cubic meters more.",usedSpace - roomVolume);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment