#C3751. Library Book Borrowing System
Library Book Borrowing System
Library Book Borrowing System
A local library requires an automated system to manage the borrowing and returning of its books. Each book is identified by a unique alphanumeric ID. The system must handle three types of operations that are communicated via textual queries:
- BORROW book_id: Marks the book as borrowed.
- RETURN book_id: Marks the book as returned.
- QUERY book_id: Checks if the book is currently borrowed. The output should be BORROWED if the book is still borrowed or AVAILABLE if it has been returned.
The queries are provided line by line and the input ends with a line containing the word END
. Your task is to implement the system and output the correct response for each QUERY
command.
Ensure that your solution reads from stdin and writes to stdout.
Note: Any formulas or conditions should be expressed in \( \LaTeX \) format if needed. In this problem no complex formulas are involved.
inputFormat
The input is given on standard input (stdin) and consists of multiple lines. Each line is one of the following commands:
- BORROW book_id
- RETURN book_id
- QUERY book_id
The input terminates with a line containing END. You may assume that book_id
represents a non-empty alphanumeric string without spaces.
outputFormat
For each QUERY book_id command, output a single line with either BORROWED or AVAILABLE indicating the current status of the book.
## sampleBORROW book123
BORROW book456
QUERY book123
RETURN book123
QUERY book123
QUERY book456
RETURN book456
QUERY book789
END
BORROWED
AVAILABLE
BORROWED
AVAILABLE
</p>