LIBRARY MANAGEMENT SYSTEM
Introduction
A Library Management System is a program used to manage the basic operations
of a library. It helps in maintaining records of books and allows users to perform
operations such as adding books, issuing books, returning books, and searching for
books.
This project is developed using Java programming language. It uses concepts
such as classes, objects, Arrays, loops and conditional statements to store and
manage the book details efficiently.
The system helps reduce manual work and ensures better management of library
resources.
Objectives of the Project
The main objectives of the Library Management System are:
To maintain records of books in the library.
To add new books to the library database.
To issue books to users.
To return issued books.
To search books by title or author.
To display the list of available books.
Software and Hardware Requirements
Hardware Requirements
Computer or Laptop
Minimum 4 GB RAM
Software Requirements
Java Development Kit (JDK)
Any Java IDE such as BlueJ / Eclipse / IntelliJ
Problem Definition
Managing a library manually is difficult and time-consuming. Keeping track of
issued books, returned books, and available books can lead to errors.
Therefore, a computerized Library Management System is required to automate
the process and make library management easier and more accurate.
Algorithm
Algorithm for Library Management System
1. Start the program.
2. Create a class Book with the following data members:
o Book ID
o Book Title
o Author Name
o Issue Status (issued or not issued)
3. Create an array of Book objects to store all book records.
4. Display the main menu with the following options:
i. Add Book
ii. Issue Book
iii. Return Book
iv. Search Book
v. Display Available Books
vi. Exit
5. Accept the user's choice.
6. If the user selects Add Book:
o Input Book ID, Title, and Author.
o Create a new Book object.
o Add the book object to the Array.
o Display confirmation message.
7. If the user selects Issue Book:
o Input the Book ID.
o Search for the book in the Array.
o If the book exists and is not issued:
Change the issue status to true.
Display "Book Issued Successfully".
o Otherwise display "Book not available".
8. If the user selects Return Book:
o Input the Book ID.
o Search for the book in the Array.
o If the book is issued:
Change the issue status to false.
Display "Book Returned Successfully".
o Otherwise display "Invalid Book ID".
9. If the user selects Search Book:
o Input the title of the book.
o Search the Array for a matching title.
o If found, display book details.
o Otherwise display "Book not found".
[Link] the user selects Display Available Books:
Traverse through the Array.
Display details of all books whose issue status is false.
[Link] the user selects Exit:
Terminate the program.
[Link] steps 4–11 until the user selects Exit.
[Link] the program.
Variable Declaration
Variable Type Purpose
books[] books array Stores book objects
count int Number of books stored
id int Book ID
title String Book title
author String Author name
sc Scanner Used to take user input
choice int Stores menu selection
issued boolean Book issue status
Program (Java Code)
import [Link];
class Book
{
int id;
String title;
String author;
boolean issued;
// Constructor
Book(int i, String t, String a)
{
id = i;
title = t;
author = a;
issued = false;
}
// Method to display book details
void display()
{
[Link]("Book ID : " + id);
[Link]("Title : " + title);
[Link]("Author : " + author);
if(issued)
[Link]("Status : Issued");
else
[Link]("Status : Available");
[Link]("----------------------------");
}
}
public class LibraryManagement
{
static Scanner sc = new Scanner([Link]);
static Book books[] = new Book[100];
static int count = 0;
// Method to add a book
static void addBook()
{
[Link]("Enter Book ID: ");
int id = [Link]();
[Link]();
[Link]("Enter Book Title: ");
String title = [Link]();
[Link]("Enter Author Name: ");
String author = [Link]();
books[count] = new Book(id, title, author);
count++;
[Link]("Book added successfully.");
}
// Method to issue a book
static void issueBook()
{
[Link]("Enter Book ID to issue: ");
int id = [Link]();
for(int i = 0; i < count; i++)
{
if(books[i].id == id && !books[i].issued)
{
books[i].issued = true;
[Link]("Book issued successfully.");
return;
}
}
[Link]("Book not available.");
}
// Method to return a book
static void returnBook()
{
[Link]("Enter Book ID to return: ");
int id = [Link]();
for(int i = 0; i < count; i++)
{
if(books[i].id == id && books[i].issued)
{
books[i].issued = false;
[Link]("Book returned successfully.");
return;
}
}
[Link]("Invalid Book ID.");
}
// Method to search a book by title
static void searchBook()
{
[Link]();
[Link]("Enter Book Title to search: ");
String title = [Link]();
for(int i = 0; i < count; i++)
{
if(books[i].[Link](title))
{
books[i].display();
return;
}
}
[Link]("Book not found.");
}
// Method to display available books
static void displayBooks()
{
boolean found = false;
[Link]("\nAvailable Books:\n");
for(int i = 0; i < count; i++)
{
if(!books[i].issued)
{
books[i].display();
found = true;
}
}
if(!found)
{
[Link]("No books available.");
}
}
// Main method
public static void main(String args[])
{
int choice;
do
{
[Link]("\n------ Library Menu ------");
[Link]("1. Add Book");
[Link]("2. Issue Book");
[Link]("3. Return Book");
[Link]("4. Search Book");
[Link]("5. Display Available Books");
[Link]("6. Exit");
[Link]("Enter your choice: ");
choice = [Link]();
switch(choice)
{
case 1:
addBook();
break;
case 2:
issueBook();
break;
case 3:
returnBook();
break;
case 4:
searchBook();
break;
case 5:
displayBooks();
break;
case 6:
[Link]("Exiting program...");
break;
default:
[Link]("Invalid choice.");
}
} while(choice != 6);
}
}
Sample Output
--- Library Menu ---
1. Add Book
2. Issue Book
3. Return Book
4. Search Book
5. Display Available Books
6. Exit
Enter choice: 1
Enter Book ID: 101
Enter Book Title: Java Programming
Enter Author Name: James Gosling
Book added successfully!
Conclusion
The Library Management System successfully demonstrates the use of Java
programming concepts such as classes, objects, loops, and conditional statements.
This system helps manage library records efficiently and reduces manual work. The
program can be further improved by adding features like file storage, graphical
interface, and user authentication.