AOOP
AOOP
DEPARTMENT OF COMPUTER
ENGINEERING
GUIDED BY:
Mr. Nikunj Tailor PREPARED BY:
Page | 1
Input :
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public LibraryManagementSystem() {
books = new ArrayList<>();
}
Page | 2
System.out.println(book.getId() + "\t" + book.getTitle() + "\t\t" + book.getAuthor());
}
}
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: ");
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