A Micro Project report on
Implement Library Management System.
Submitted to the CMR Institute of Technology in partial fulfillment of the
requirement for the award of the Laboratory of
OOP Through Java Lab
of
II- B.Tech. I-Semester
In
COMPUTER SCIENCE AND ENGINEERING (Cyber Security)
Submitted by
G.ACHYUTH (22R01A6222)
G.SAI TRISHUL (22R01A6223)
G.EESHWAR SAI (22R01A6224)
G. CHETAN (22R01A6225)
G. NARESH (22R01A6226)
G.ABHIRAM (22R01A6227)
I. SAI VARSHITH (22R01A6228)
Under the Guidance Of
Mr.P.KRISHNAIAH,M.Tech
Asst. Professor, CSE Dept
CMR INSTITUTE OF TECHNOLOGY
(UGC AUTONOMUS)
(Approved by AICTE, Affiliated to JNTU, Kukatpally, Hyderabad)
Kandlakoya, Medchal Road, Hyderabad – 501401
2023-2024
1
CMR INSTITUTE OF TECHNOLOGY
(UGC AUTONOMUS)
(Approved by AICTE, Affiliated to JNTU, Kukatpally, Hyderabad)
Kandlakoya, Medchal Road, Hyderabad.
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
(Cyber Security)
CERTIFICATE
This is to certify that a Micro Project entitled with: “ Implement Library
Management System “is being Submitted By
G.ACHYUTH (22R01A6222)
G.SAI TRISHUL (22R01A6223)
G.EESHWAR SAI (22R01A6224)
G. CHETAN (22R01A6225)
G. NARESH (22R01A6226)
G.ABHIRAM (22R01A6227)
I. SAI VARSHITH (22R01A6228)
In partial fulfillment of the requirement for award of the OOP Through Java Lab
of II-B. Tech I- Semester in CSE(CS) towards a record of a bonafide work
carried out under our guidance and supervision.
Signature of Faculty Signature of HOD
Mr.P.Krishnaiah,M.Tech Mr.A.Prakash,M.Tech
2
ACKNOWLEDGEMENT
We are extremely grateful to Dr. M. Janga Reddy, Director, Dr. B.
Satyanarayana, Principal and Mr.A.Prakash, Head of Department, Dept of
Computer Science and Engineering(CS), CMR Institute of Technology for their
inspiration and valuable guidance during entire duration.
We are extremely thankful to our OOP Through Java Lab faculty in-charge
Mr. P.Krishnaiah Computer science and engineering department (CS) CMR
Institute of Technology for his constant guidance, encouragement and moral
support throughout the project.
We express our thanks to all staff members and friends for all the help
and coordination extended in bringing out this Project successfully in time.
Finally, we are very much thankful to our parents and relatives who
guided directly or indirectly for successful completion of the project.
G.ACHYUTH (22R01A6222)
G.SAI TRISHUL (22R01A6223)
G.EESHWAR SAI (22R01A6224)
G. CHETAN (22R01A6225)
G. NARESH (22R01A6226)
G.ABHIRAM (22R01A6227)
I. SAI VARSHITH (22R01A6228)
3
INDEX:
Sl. No. Particulars Page No.
1. Abstract 5
2. Introduction 6
3. Source code 7-9
4. Explanation 10-11
5. Expected output 12-13
6. Original output 14
7. Conclusion 15
8. References 16
4
ABSTRACT:
This project involves implementing a Library Management System (LMS) using the Object-
Oriented Programming (OOP) paradigm in Java with the Object-Oriented Programming System
(OOPS) concepts, primarily focusing on encapsulation, inheritance, and polymorphism. The LMS
utilizes the features of the Java programming language, including the use of classes and objects, to
model the entities such as books, users, and transactions. The integration of the Java Database
Connectivity (JDBC) ensures efficient data management, allowing seamless interaction between
the application and the backend database. This Object-Oriented approach enhances code
organization, reusability, and maintainability, making the Library Management System scalable for
future enhancements and modifications.
5
INTRODUCTION:
In the realm of code and data, our venture delves into the creation of a Library Management System
(LMS) using the mighty capabilities of Java. Going beyond the surface, this project plunges into
the intricacies of Object-Oriented Programming (OOP) to craft a system that not only handles
books and users but does so with finesse. As we navigate the intricate web of classes, objects, and
Java Database Connectivity (JDBC), this LMS promises to redefine how libraries function in the
digital age. Brace yourself for a journey into the code-driven evolution of traditional libraries,
where Java becomes the architect of a new chapter in resource management..
6
Source code:
import java.util.ArrayList;
import java.util.Scanner;
class Book {
private String title;
private String author;
private boolean available;
public Book(String title, String author) {
this.title = title;
this.author = author;
this.available = true;
}
public String getTitle() {
return title;
}
public String getAuthor() {
return author;
}
public boolean isAvailable() {
return available;
}
public void setAvailable(boolean available) {
this.available = available;
}
}
Class Library {
private ArrayList<Book> books;
public Library() {
this.books = new ArrayList<>();
}
public void addBook(Book book) {
books.add(book);
}
public void displayBooks() {
7
System.out.println("Library Books:");
for (Book book : books) {
System.out.println("Title: " + book.getTitle() + "\tAuthor: " +
book.getAuthor() +
"\tAvailable: " + (book.isAvailable() ? "Yes" : "No"));
}
System.out.println();
}
public Book findBook(String title) {
for (Book book : books) {
if (book.getTitle().equalsIgnoreCase(title)) {
return book;
}
}
return null;
}
}
public class LibraryManagementSystem {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Library library = new Library();
while (true) {
System.out.println("1. Add Book");
System.out.println("2. Display Books");
System.out.println("3. Borrow Book");
System.out.println("4. Return Book");
System.out.println("5. Exit");
System.out.print("Enter your choice: ");
int choice = scanner.nextInt();
scanner.nextLine(); // consume the newline character
switch (choice) {
case 1:
System.out.print("Enter book title: ");
String title = scanner.nextLine();
System.out.print("Enter author name: ");
String author = scanner.nextLine();
Book newBook = new Book(title, author);
library.addBook(newBook);
System.out.println("Book added successfully!\n");
8
break;
case 2:
library.displayBooks();
break;
case 3:
System.out.print("Enter the title of the book to borrow: ");
String borrowTitle = scanner.nextLine();
Book borrowBook = library.findBook(borrowTitle);
if (borrowBook != null && borrowBook.isAvailable()) {
borrowBook.setAvailable(false);
System.out.println("Book borrowed successfully!\n");
} else {
System.out.println("Book not available or does not exist.\n");
}
break;
case 4:
System.out.print("Enter the title of the book to return: ");
String returnTitle = scanner.nextLine();
Book returnBook = library.findBook(returnTitle);
if (returnBook != null && !returnBook.isAvailable()) {
returnBook.setAvailable(true);
System.out.println("Book returned successfully!\n");
} else {
System.out.println("Book cannot be returned or does not exist.\n");
}
break;
case 5:
System.out.println("Exiting Library Management System. Goodbye!");
System.exit(0);
default:
System.out.println("Invalid choice. Please try again.\n");
}
}
}
}
9
Explanation:
Library Management System.
1. Book Class:
- Attributes: title (String), author (String), available (boolean).
- Constructor: Initializes a book with a title, author, and sets availability to true.
- Getter methods: getTitle( ), getAuthor( ), isAvailable( ).
- Setter method: setAvailable(boolean).
2. Library Class:
- Attributes: books (ArrayList of Book objects).
- Constructor: Initializes an empty list of books.
- Methods:
- addBook(Book book): Adds a book to the library.
- displayBooks( ): Displays information about all books in the library.
- findBook(String title) : Searches for a book by title and returns it if found.
3. Library Management System Class (Main):
- Uses a Scanner for user input.
- Implements a menu-driven interface within an infinite loop.
- Menu options:
1. Add Book: Takes user input for title and author to create a new book and adds
it to the library.
2. Display Books: Prints information about all books in the library.
3. Borrow Book: Allows the user to borrow a book by entering its title. Updates
book availability.
4. Return Book: Allows the user to return a borrowed book by entering its title.
Updates book availability.
5. Exit: Terminates the program.
10
The code provides a basic yet functional Library Management System, offering users
the ability to interact with the library by adding books, displaying the book catalog,
borrowing, and returning books. The use of object-oriented principles enhances code
organization and readability.
11
Expected Output:
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
Enter your choice: 1
Enter book title: The Great Gatsby
Enter author name: F.Scott fitzgerald
Book added successfully!
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
Enter your choice: 1
Enter book title: Ramayanam
Enter author name: Valmi Maharshi
Book added successfully!
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
Enter your choice: 2
Library Books:
Title: The Great Gatsby Author: F.Scott fitzgerald
Title: Ramayanam Author: Valmi Maharshi Available: Yes
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
12
Enter your choice: 3
Enter the title of the book to borrow: Ramayanam
Book borrowed successfully!
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
Enter your choice: 4
Enter the title of the book to return: Ramayanam
Book returned successfully!
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
Enter your choice: 5
Exiting Library Management System. Goodbye!
13
Original Output :
14
Conclusion:
The Library Management System (LMS) implemented in Java showcases the power
of Object-Oriented Programming (OOP) in creating a functional and user-friendly
solution. The modular structure, with distinct classes for books and the library,
enhances code organization and readability. The main class, Library Management
System, orchestrates user interactions seamlessly through a menu-driven interface.
The perpetual loop ensures continuous engagement until the user decides to exit.
This system not only simplifies library operations but also serves as a foundational
project for understanding OOP concepts and Java programming.
15
References :
o https://code-projects.org/library-management-system-in-java-with-source-code/
o https://github.com/topics/library-management-system?l=java
o https://www.upgrad.com/blog/library-management-system-project-in-java/
16