Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayDeque;
- import java.util.Deque;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- Deque<String> queue = new ArrayDeque<>();
- String line = "";
- while (!"print".equals(line=scan.nextLine())){
- if (!"cancel".equals(line)){
- queue.offer(line);
- }else {
- if (!queue.isEmpty()){
- System.out.println("Canceled " + queue.poll());
- }else {
- System.out.println("Printer is on standby");
- }
- }
- }
- System.out.println(String.join(System.lineSeparator(), queue));
- // while (queue.size() != 0){
- // System.out.println(queue.poll());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement