Java Programming Exercise: Library Book Management System
Objective:
Build a basic Java program that simulates a small library system. The program should:
Store a list of available books
Allow adding/removing books using a stack
Handle a book borrowing queue
Use functions to organize code
Practice working with variables and arrays
Requirements & Instructions:
1. Declare Variables and Arrays
Create an array of strings to store a maximum of 10 book titles.
Use an integer variable to keep track of the number of books in the
library.
2. Functions (Methods)
Create at least the following methods:
o addBook(String bookTitle) – Adds a book to the array using a
Stack
o removeBook() – Removes the most recently added book from
the Stack
o displayBooks() – Displays all books in the array
o borrowBook(String bookTitle) – Adds a user request to a Queue
o serveNextBorrower() – Processes the next user in the borrow
queue
3. Stacks
Create stack functions init, push, pop and peek
4. Queues
Create queue functions init, enque and deque
Example Console Output:
Bonus Tasks:
Validate if the array is full before adding a book.
Prevent duplicate book titles.
Add a search method to check if a specific book is available.
Count how many times a book was borrowed.