KEMBAR78
DSA Java Activity | PDF
0% found this document useful (0 votes)
10 views2 pages

DSA Java Activity

The document outlines a Java programming exercise to create a Library Book Management System. It includes requirements for managing a list of books using stacks and queues, with specific methods for adding, removing, displaying, and borrowing books. Additionally, it suggests bonus tasks such as validating array capacity, preventing duplicates, searching for books, and tracking borrow counts.

Uploaded by

Hasna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views2 pages

DSA Java Activity

The document outlines a Java programming exercise to create a Library Book Management System. It includes requirements for managing a list of books using stacks and queues, with specific methods for adding, removing, displaying, and borrowing books. Additionally, it suggests bonus tasks such as validating array capacity, preventing duplicates, searching for books, and tracking borrow counts.

Uploaded by

Hasna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

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.

You might also like