Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on.You've got this!
Lesson 9 of 10
Mini Project: Library System - Part 1 (Book Record)
Start the Library Management System that runs through all 12 modules. This first part uses only Module 1 concepts: variables, types, methods, arrays, strings, and Scanner. We'll model a Book and build a simple console lookup program.
Project Requirements
- Model a book with: title, author, ISBN, price, available (boolean)
- Store a small catalog as parallel arrays
- Accept user input to search by title (case-insensitive)
- Display matched book details formatted with String.format
- Handle 'book not found' gracefully
Library Part 1 - Book Catalog
import java.util.Scanner;
public class LibraryCatalog {
static String[] titles = {"Clean Code", "Effective Java", "The Pragmatic Programmer"};
static String[] authors = {"Robert Martin", "Joshua Bloch", "Andrew Hunt"};
static String[] isbns = {"978-0132350884", "978-0134685991", "978-0135957059"};
static double[] prices = {39.99, 44.99, 49.99};
static boolean[] available = {true, false, true};
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter book title to search: ");
String query = scanner.nextLine().trim();
scanner.close();
int foundIndex = findBook(query);
if (foundIndex == -1) {
System.out.println("Book not found: " + query);
} else {
displayBook(foundIndex);
}
}
static int findBook(String query) {
for (int i = 0; i < titles.length; i++) {
if (titles[i].equalsIgnoreCase(query)) return i;
}
return -1; // sentinel value: -1 = not found
}
static void displayBook(int index) {
System.out.println("═".repeat(40));
System.out.printf("Title : %s%n", titles[index]);
System.out.printf("Author : %s%n", authors[index]);
System.out.printf("ISBN : %s%n", isbns[index]);
System.out.printf("Price : $%.2f%n", prices[index]);
System.out.printf("Status : %s%n", available[index] ? "Available" : "Checked Out");
System.out.println("═".repeat(40));
}
}Quick Quiz
Tip
Tip
Practice Mini Project Library System Part 1 Book Record in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Visual architecture and concepts for Mini Project: Library System - Part 1 (Book Record)
Practice Task
Note
Practice Task - (1) Write a working example of Mini Project Library System Part 1 Book Record from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Common Mistake
Warning
A common mistake with Mini Project Library System Part 1 Book Record is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready java code.
Key Takeaways
- Start the Library Management System that runs through all 12 modules.
- Model a book with: title, author, ISBN, price, available (boolean)
- Store a small catalog as parallel arrays
- Accept user input to search by title (case-insensitive)
Finished this lesson?