Library Book Inventory
Library Book Inventory
Create a Java program for managing library books. Use a Book class with attributes: bookId,
title, author, and availability. Allow adding, viewing, and checking availability of books using
an array of objects.
🎯 Objective:
To implement arrays of objects and use basic class design to model a library system.
🧠 Class Structure:
class Book {
int bookId;
String title;
String author;
boolean isAvailable;
this.bookId = bookId;
this.title = title;
this.author = author;
this.isAvailable = true;
void display() {
System.out.println(bookId + " | " + title + " | " + author + " | " + (isAvailable ? "Available"
: "Not Available"));
Main Program:
import java.util.Scanner;
int count = 0;
while (true) {
sc.nextLine();
switch (choice) {
case 1:
int id = sc.nextInt();
sc.nextLine();
} else {
System.out.println("Library full!");
break;
case 2:
books[i].display();
}
break;
case 3:
return;