Java MP
Java MP
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.
2
ACKNOWLEDGEMENT
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:
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
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;
}
Class Library {
private ArrayList<Book> books;
public Library() {
this.books = new ArrayList<>();
}
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: ");
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);
case 4:
System.out.print("Enter the title of the book to return: ");
String returnTitle = scanner.nextLine();
Book returnBook = library.findBook(returnTitle);
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:
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.
11
Expected Output:
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
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
1. Add Book
2. Display Books
3. Borrow Book
4. Return Book
5. Exit
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