#C13921. Library Book Borrowing System
Library Book Borrowing System
Library Book Borrowing System
This problem requires you to implement a simple library system that supports adding new books, borrowing them, returning them, and checking their availability status. Each book is represented by a unique integer book_id, a title, and an author. The book status, which is either \(available\) or \(borrowed\), changes based on the operations performed. You must handle error cases appropriately by printing the specified error messages.
inputFormat
The first line contains an integer \(T\) (\(T \geq 1\)), which represents the number of operations. The next \(T\) lines each contain an operation in one of the following formats:
add book_id title author
: Add a new book. If book_id already exists, output "Book ID already exists."; otherwise, output "Book added successfully."borrow book_id
: Borrow a book. If the book does not exist, output "Book ID not found."; if the book is already borrowed, output "Book already borrowed."; otherwise, output "Book borrowed successfully."return book_id
: Return a book. If the book does not exist, output "Book ID not found."; if the book was not borrowed, output "Book was not borrowed."; otherwise, output "Book returned successfully."status book_id
: Check the book's status. If the book does not exist, output "Book ID not found."; otherwise, output the book status (either "available" or "borrowed").
outputFormat
For each operation provided in the input, output the corresponding result message on a new line.
## sample6
add 1 1984 Orwell
add 2 Dune Herbert
status 1
borrow 1
status 1
return 1
Book added successfully.
Book added successfully.
available
Book borrowed successfully.
borrowed
Book returned successfully.
</p>