Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package OldExams;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- public class OwnBussiness {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- int w = Integer.parseInt(reader.readLine());
- int l = Integer.parseInt(reader.readLine());
- int h = Integer.parseInt(reader.readLine());
- int n = 0;
- int space = w * l * h;
- int freespace = 0;
- String command = reader.readLine();
- while (!command.equals("Done")){
- n = Integer.valueOf(command);
- if (space >= n){
- space -= n;
- command = reader.readLine();
- continue;
- }
- freespace = n - space;
- break;
- }
- if (freespace == 0){
- System.out.printf("%d Cubic meters left.",space);
- }else {
- System.out.printf("No more free space! You need %d Cubic meters more.",freespace);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment