P3
P3
ArrayList;
import java.util.Scanner;
class Book {
private String bookId;
private String title;
private String author;
private boolean isIssued;
do {
System.out.println("\n***** LIBRARY MANAGEMENT SYSTEM *****");
System.out.println("1. Add Book");
System.out.println("2. View All Books");
System.out.println("3. Search Book by ID");
System.out.println("4. Issue Book");
System.out.println("5. Return Book");
System.out.println("6. Exit");
System.out.print("Enter your choice: ");
choice = sc.nextInt();
sc.nextLine(); // consume newline
switch (choice) {
case 1:
addBook();
break;
case 2:
viewBooks();
break;
case 3:
searchBook();
break;
case 4:
issueBook();
break;
case 5:
returnBook();
break;
case 6:
System.out.println("Thank you for using the Library System!");
break;
default:
System.out.println("Invalid choice. Try again!");
}
} while (choice != 6);
}
if (!found) {
System.out.println("Book not found.");
}
}