Queue Management: Waiting Line System
Problem Description
Queue Management: Waiting Line System
In this problem, you will create a program that manages a customer waiting list using Queue<String> in FIFO (First-In-First-Out) order and displays the waiting queue and serving order to standard output.
Learning Objectives
Apply-Level Learning Goal
Implement FIFO (First-In-First-Out) data management using Queue at practical level.
Practical Goals (4 items)
- Declare and initialize Queue [Apply]
- Perform queue operations with offer() and poll() [Apply]
- Implement conditional processing based on queue state [Apply]
- Explain reasoning for choosing LinkedList vs ArrayDeque [Analyze]
Real-World Scenario
Scenario Type: Both
Business Context
Imagine a waiting system at a popular ramen shop. Customers are added to the list in arrival order, and when seats become available, customers are served from the front. Fairness is important; cutting in line is not allowed.
System Context
Message queues and task queues work on the same principle. Web servers add received requests to a queue, and worker threads process them in order. This smooths out peak-time load.
Why This Matters
- Foundation pattern for fair order processing
- Basis of message queues, task queues
- Element of event-driven architecture
Input
Line 1: Number of customers (integer, 1-10 people)
Lines 2~N+1: Customer name (string)
Output
Waiting Queue:
1. [name 1]
2. [name 2]
...
Serving Order:
[name 1]
[name 2]
...
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up