0% found this document useful (0 votes)
4 views

AOOP

The document outlines a micro-project on a Library Management System developed as part of a Computer Engineering course. It includes Java code for managing books, allowing users to add, display, and search for books by title. The project is prepared by students under the guidance of Mr. Nikunj Tailor at A.Y. Dadabhai Technical Institute.

Uploaded by

muvved
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)
4 views

AOOP

The document outlines a micro-project on a Library Management System developed as part of a Computer Engineering course. It includes Java code for managing books, allowing users to add, display, and search for books by title. The project is prepared by students under the guidance of Mr. Nikunj Tailor at A.Y. Dadabhai Technical Institute.

Uploaded by

muvved
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/ 5

MICRO – PROJECT On

“Library management system”


[COMPUTER ENGINEERING]

DEPARTMENT OF COMPUTER
ENGINEERING

A.Y. DADABHAI TECHNICAL


INSTITUTE
Mahuvej Road, B/H old Mariyambai
hospitalKosamba -394120(Gujarat)

Subject Name: AOOP


Subject Code: 4340701

GUIDED BY:
Mr. Nikunj Tailor PREPARED BY:

Maaz Patel : 216010307040


Hanzala Qureshi : 216010307046
Ziya Sheikh : 216010307058
Paresh Solanki : 216010307062
Mohammad V. : 216010307070

Page | 1
Input :
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class LibraryManagementSystem {


private static class Book {
private int id;
private String title;
private String author;

public Book(int id, String title, String author) {


this.id = id;
this.title = title;
this.author = author;
}

public int getId() {


return id;
}

public String getTitle() {


return title;
}

public String getAuthor() {


return author;
}
}

private List<Book> books;

public LibraryManagementSystem() {
books = new ArrayList<>();
}

public void addBook(int id, String title, String author) {


Book newBook = new Book(id, title, author);
books.add(newBook);
System.out.println("Book added successfully.");
}

public void displayBooks() {


System.out.println("Book ID\tTitle\t\tAuthor");
for (Book book : books) {

Page | 2
System.out.println(book.getId() + "\t" + book.getTitle() + "\t\t" + book.getAuthor());
}
}

public void searchBook(String title) {


for (Book book : books) {
if (book.getTitle().equalsIgnoreCase(title)) {
System.out.println("Book found:");
System.out.println("Book ID: " + book.getId());
System.out.println("Title: " + book.getTitle());
System.out.println("Author: " + book.getAuthor());
return;
}
}
System.out.println("Book not found with the given title.");
}

public static void main(String[] args) {


Scanner scanner = new Scanner(System.in);
LibraryManagementSystem library = new LibraryManagementSystem();

while (true) {
System.out.println("\nLibrary Management System");
System.out.println("1. Add Book");
System.out.println("2. Display Books");
System.out.println("3. Search Book by Title");
System.out.println("4. Exit");
System.out.print("Enter your choice: ");

int choice = scanner.nextInt();


scanner.nextLine(); // Consume the newline left by nextInt()

switch (choice) {
case 1:
System.out.print("Enter Book ID: ");
int id = scanner.nextInt();
scanner.nextLine(); // Consume the newline left by nextInt()
System.out.print("Enter Book Title: ");
String title = scanner.nextLine();
System.out.print("Enter Book Author: ");
String author = scanner.nextLine();
library.addBook(id, title, author);
break;
case 2:
library.displayBooks();
break;

Page | 3
case 3:
System.out.print("Enter Book Title to search: ");
String searchTitle = scanner.nextLine();
library.searchBook(searchTitle);
break;
case 4:
System.out.println("Exiting Library Management System. Goodbye!");
scanner.close();
System.exit(0);
default:
System.out.println("Invalid choice. Please enter a valid option.");
}
}
}
}

Page | 4
Output :

Page | 5

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy