Library Fine Calculator
Library Fine Calculator
Hinduja
Sindhi Model Senior Secondary School
(Affiliated to the Central Board of Secondary Education, Delhi)
Roll No:
2024 - 2025
DEPARTMENT OF: INFORMATION TECHNOLOGY
1|Page
Seth P.D. Hinduja
_
Submitted for the All-India Senior School Certificate Examination
2024 – 2025(Practical Examination) in Information
Technology(802) Seth P.D. Hinduja Sindhi Model Senior
Secondary School, Chennai.
………………… ………………….
2|Page
Date :…………… Date :………………
TABLE OF CONTENTS
2 ACKNOWLEDGEMENT 5
3 PROJECT DESCRIPTION 6
4 SYSTEM ANALYSIS 4
5 SYSTEM DESIGN 5
6 PRACTICAL ANALYSIS 6
7 PROGRAM 7
8 OUTPUT SCREENS 18
9 CONCLUSION 23
10 BIBLIOGRAPHY 24
3|Page
CERTIFICATE
guidance. This report or an identical report on this topic has not been
submitted for any other examination and does not form a part of any
..............................
Signature of Teacher/Guide
4|Page
ACKNOWLEDGEMENT
The successful completion of this project would not have been possible
without the unwavering support and encouragement of many individuals,
to whom I am deeply grateful.
First and foremost, I would like to thank God for providing me with the
strength, wisdom, and ability to successfully complete this project.
5|Page
PROJECT DESCRIPTION
Library Fine Calculator
help librarians and users easily calculate overdue fines for books. The
program stores details such as the book ID, title, due date, and return
date. If a book is returned after the due date, a fine of ₹5 per day is
calculated and displayed. The application uses Java's date handling and
Fine Calculation:
Automatically calculates a fine of ₹5 per day if a book is returned late.
Date Validation:
Ensures correct date format (dd-MM-yyyy) and handles errors for invalid dates.
Book Record Management:
Allows storing multiple book entries with details like book ID, title, due date, return
date, and fine.
User-Friendly Menu:
Simple menu options for adding book details, displaying fines, and exiting the
application.
Accurate Results:
Uses date difference to correctly calculate the number of days a book is overdue.
6|Page
System Analysis:
Problem Definition:
In libraries, calculating fines for overdue books manually can be time-consuming
and prone to errors. This project aims to simplify the process by providing an
automated way to calculate and display fines based on the return date of the book.
Proposed Solution:
The proposed solution is a console-based Java application where users can:
Enter the details of borrowed books, including due and return dates.
Automatically calculate fines based on the number of days a book is overdue.
Display the fine details for each book.
Software Requirements:
Programming Language: Java
Development Environment: NetBeans IDE
Java Version: JDK 8 or above
Operating System: Windows 11 Pro
Hardware Requirements:
Processor: Intel Core i7-11700 @ 2.50 GHz
RAM: 8 GB
Storage: At least 1 GB of free space
Functional Requirements
The system should fulfill the following key requirements:
Add Book Details:
User can enter book information like Book ID, Title, Due Date, and Return Date.
Check Date Format:
System verifies that dates are entered correctly (dd-MM-yyyy format).
Calculate Fine:
System calculates a fine of ₹5 per day if the book is returned after the due date.
Store Records:
System stores details of all entered books along with their calculated fines.
7|Page
Show Fine Details:
System can display the list of all books with their fine amounts.
User Menu:
Provides options to add book details, view fines, or exit the program.
Non-Functional Requirements
Usability : The system should be simple and easy to use with a clear, text based
menu.
Performance : The application should handle basic book management operations
quickly, even with a few hundred records.
Reliability : The system should provide accurate updates of book availability.
Maintainability : The code should be modular and easy to update or extend with
additional features.
System Design
Class Design
Book
bookId: String
title: String
dueDate: String
returnDate: String
fine: double
LibraryFineCalculator
books: ArrayList<Book>
scanner: Scanner
main(String[]): void
addBookDetails(): void
displayFineDetails():
void
8|Page
Practical Analysis:
The program efficiently handles date parsing and calculation of the difference
between due and return dates using the SimpleDateFormat class. It also uses an
ArrayList to store multiple book records, ensuring dynamic handling of book
entries. Error handling is implemented for incorrect date formats using
ParseException.
Key Features:
Automated fine calculation.
User-friendly input and output prompts.
Error handling for invalid date entries.
Simple and efficient code structure using Object-Oriented Programming (OOP).
class Book {
9|Page
private String bookId;
private String title;
private String dueDate;
private String returnDate;
private double fine;
// Constructor
public Book(String bookId, String title, String dueDate, String returnDate) {
this.bookId = bookId;
this.title = title;
this.dueDate = dueDate;
this.returnDate = returnDate;
this.fine = calculateFine();
}
// Method to calculate fine based on the number of days late
private double calculateFine() {
SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
try {
Date due = sdf.parse(dueDate);
Date returned = sdf.parse(returnDate);
// Calculate the difference in milliseconds
long differenceInMilliSeconds = returned.getTime() - due.getTime();
long daysLate = differenceInMilliSeconds / (1000 * 60 * 60 * 24);
// Fine is Rs. 5 per day if the book is returned late
return (daysLate > 0) ? daysLate * 5 : 0;
} catch (ParseException e) {
System.out.println("Invalid date format. Please use dd-MM-yyyy.");
return 0;
}
}
10 | P a g e
public String toString() {
return "Book ID: " + bookId + ", Title: " + title +
", Due Date: " + dueDate + ", Return Date: " + returnDate +
", Fine: ₹" + fine;
}
}
public class LibraryFineCalculator {
private static ArrayList<Book> books = new ArrayList<>();
private static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int choice;
do {
System.out.println("\nLibrary Fine Calculator");
System.out.println("1. Enter Book Details");
System.out.println("2. Display Fine Details");
System.out.println("3. Exit");
System.out.print("Enter your choice: ");
choice = scanner.nextInt();
scanner.nextLine(); // Consume newline
switch (choice) {
case 1: addBookDetails(); break;
case 2 : displayFineDetails();break;
case 3 : System.out.println("Exiting the system. Goodbye!");break;
default : System.out.println("Invalid choice! Please try again.");
}
} while (choice != 3);
}
11 | P a g e
private static void addBookDetails() {
System.out.print("Enter Book ID: ");
String bookId = scanner.nextLine();
System.out.print("Enter Book Title: ");
String title = scanner.nextLine();
System.out.print("Enter Due Date (dd-MM-yyyy): ");
String dueDate = scanner.nextLine();
System.out.print("Enter Return Date (dd-MM-yyyy): ");
String returnDate = scanner.nextLine();
Book book = new Book(bookId, title, dueDate, returnDate);
books.add(book);
System.out.println("Book details added successfully!");
}
// Method to display fine details
private static void displayFineDetails() {
if (books.isEmpty()) {
System.out.println("No book records found.");
} else {
System.out.println("\nFine Details:");
for (Book book : books) {
System.out.println(book);
}
}
}
}
Step 4: Run the Project
1. Right click on Library Fine Calculator System .java
2. Select Run File or press `Shift F6`.
12 | P a g e
Project Explanation:
How It Works:
1. Entering Book Details:
- The user can enter information about a book, including:
- Book ID : A unique identifier for the book.
- Book Title : The title of the book.
- Due Date : The date by which the book should be returned (in dd-MM-yyyy
format).
- Return Date : The actual date when the book is returned (also in dd-MM-yyyy
format).
2. Fine Calculation:
- The system checks the Due Date and Return Date to calculate the fine.
- If the book is returned after the due date, a fine of ₹5 per day is applied.
- If the book is returned on time, there is no fine.
3. Storing Book Records:
- The system stores the entered book details and the calculated fine in a list.
- This list is used to keep track of multiple books and their overdue fines.
4. Displaying Fine Details:
- The user can view a list of all books entered, including their ID, title, due date,
return date, and the calculated fine.
- This helps the user easily check the fine status for each book.
13 | P a g e
5. User Interaction:
- The application runs in a simple, menu-driven interface. The user can:
- Enter Book Details : Input new book information.
- Display Fine Details : View the list of books and their fines.
- Exit : Close the application.
6. Error Handling:
- The system ensures correct date format (dd-MM-yyyy). If a user enters an
invalid date, an error message is shown.
- The system also handles invalid menu choices, prompting the user to try again.
Why This System?
The Library Fine Calculator System simplifies the task of managing overdue books
and fines. Instead of manually calculating fines or using paper records, this system
automates the entire process, ensuring accurate results and reducing errors. It
provides a user-friendly way for library staff or users to manage book returns and
fines efficiently.
This project is designed for ease of use, ensuring that users can quickly enter book
details, calculate fines, and view results.
14 | P a g e
OUTPUT SCREENS
1. Main Menu:
15 | P a g e
3. Display Fine Details:
16 | P a g e
5. Exit:
17 | P a g e
Conclusion:
Conclusion:
The Library Fine Calculator project successfully demonstrates the use of Java for
ability to parse dates, calculate fines, and handle user inputs showcases the strength
a practical solution for librarians to quickly and accurately calculate fines, reducing
Future Enhancements:
18 | P a g e
BIBLIOGRAPHY
19 | P a g e
20 | P a g e