package BookManagementSystem;
import java.util.Scanner;
public class Book {
// global members
static Scanner scn = new Scanner(System.in);
// Yashank Rathi 5/30/25
// Writing a blueprint of the book class.
// This class is the first branch of this project, without the
// ArrayList of books can't exist.
// data members
private String title;
private String publisherName;
private String author;
private int isbn;
private int year;
private int length;
private boolean status;
// parameterized constructor
public Book(String vtitle, String vpublisherName, String vauthor, int isbnNum,
int vyear, int vlength,
boolean vstatus) {
title = vtitle;
publisherName = vpublisherName;
author = vauthor;
isbn = isbnNum;
year = vyear;
length = vlength;
status = vstatus;
}
// getters
// returns book title
public String getTitle() {
//return value
return title;
}
// returns the publisherName
public String getPublisherName() {
//return value
return publisherName;
}
// returns the authorName
public String getAuthorName() {
//return value
return author;
}
// returns the ISBN number
public int getIsbn() {
//return value
return isbn;
}
// returns the year
public int getYear() {
//return value
return year;
}
// returns the length(Number of pages)
public int getLength() {
//return value
return length;
}
// returns is available or not
public boolean isAvailable() {
//return value
return status;
}
/* This method ask the user enter what type of book does he want.
* Fiction,Non-Fiction, or a courseBook
*/
public int getDetails() {
//declare and initialize variables
int detail;
//ask user
System.out.println("Hi the type of book given here are:Fiction, Non-Fiction
or textbook");
System.out.println("Enter 1 for Fiction, 2 for Non-Fiction,3 for Textbook: ");
detail = scn.nextInt();
//return value
return detail;
// scn.close();
}
// other methods
/*This method asks the user to type in the current date to issue a book.
* User should write the date in MM/DD/YYYY format.
* For Example:
* If Date issued it 11th of June then you have to write 6/11/25
*/
public String issueBook() {
//declare and initialize variables
String ibDate;
//ask user
System.out.println("Enter the current date issued: (MM/DD/YYYY)");
ibDate = scn.nextLine();
//return value
return ibDate;
}
/*This method calculates the days the book should be returned in.
* Normally every library gives a person 3 weeks which 21 days.
* That is how calculation is done.
* We have Assumed all months have 30 days.
* if the book is Assigned to user by 6/11/25 to so we have add 21 to this.
* Calculation:
* Issue book method was where the user entered the date, he took out the book
* So I have used that method, and used hardcoding with substring, by taking the
advantage, of this string length is never changing.
* The same way I have pulled out the month and year and stored them in
separate string variables.
* Then I have converted them into integer, by the use of the Integer.parseInt()
function.
* For example:
* 06/11/25(Entered by User)
* Then I pull the date by substring get :"11"
* Then I convert this into integer by Integer.parseInt()
* Then I add 21 days to it.
* 11+21=32 days
* That is greater than my Assumption so I subtract by 30 to get the extra days
* Then I have have add one to the month, give the user 2nd of July as return
date.
* Then in the I print it in this form (MM/DD/YYYY) 07/02/2025
* If user gave 12/11/25 then i not only add one to the month but also one to the
year, as there are only 12 months.
*/
public String returnBook() {
//declare and initialize variables
String issueDate = issueBook();
String newMonth, newDay;
String issueMonth = issueDate.substring(0, 2);
String issueDay = issueDate.substring(3, 5);
String issueYear = issueDate.substring(6);
int month = Integer.parseInt(issueMonth);
int day = Integer.parseInt(issueDay);
int year = Integer.parseInt(issueYear);
//calculate by if/else
day += 21;
if (day > 30) {//Assuming every month has no more than 30 days
day -= 30;
month += 1;
if (month > 12) {
month = 1;
year += 1;
}
}
if (month < 10)
newMonth = "0" + month;
else
newMonth = "" + month;
if (day < 10)
newDay = "0" + day;
else
newDay = "" + day;
//return value
return newMonth + "/" + newDay + "/" + year;
}
/*This method calculate the late penalty if the book not returned in time.
* Late Penalty is a kind of fee user has to provide with the book.
* It takes 6 parameters to organize when it was assigned or the actual return
date, and the day user returns the book back.
* For example:
* 07/02/2025 but user gave back at 07/08/2025
* The starting year and the endYear will most likely equal to 0.
* 2025-2025=0
* 07-07=0
* 0+0=0
* 08-02
* 6 days late!!
* So the user has pay six dollars with the book.
*/
public int latePenality(int startY, int startM, int startD, int endY, int endM, int
endD) {
//declare and initialize variables
int result;
//calculate
result= (startY - endY) * 365;
result += (startM - endM) * 31;
result += (endD-startD);
//return value
return Math.abs(result);
}
/*This method returns every value of the data member this class has.
* In String format!!
*/
public String toString() {
//declare and initialize variables
String s;
//if/else use to confirm
if(isAvailable())
s="The book is present!!";
else
s="The book is not present!!";
//return value
return "Book Title: "+getTitle() +"The Publisher of the book is: "+
getPublisherName() + "The Author of the book is: "+getAuthorName() + "The ISBN
number is: "+getIsbn() + "\n Year this book was made: "+getYear() + "The Number of
Pages this book has: "+getLength()+s;
}
}
package BookManagementSystem;
public class Customer {
// Yashank Rathi 6/1/25
// Creating a blueprint of the customer class
// data members
private int id;
private String name;
private String email;
private int phone;
// parameterized constructor
public Customer(int vid, String vname, String vemail, int phoneNum) {
id = vid;
name = vname;
email = vemail;
phone = phoneNum;
}
// getters
// returns the id
public int getId() {
//return value
return id;
}
// returns the name
public String getName() {
//return value
return name;
}
// returns the email
public String getEmail() {
//return value
return email;
}
// returns the phoneNumber
public int getPhone() {
//return value
return phone;
}
// other methods
/*This method Collects information about the user
* Like Name,Email and Phone Number
*/
public void info() {
//ask user
System.out.println("Name: " + name);
System.out.println("Email: " + email);
System.out.println("Phone: " + phone);
}
/*This method is created to keep track, how frequent the user is in returning
books, in time.
* This method does it gets the values from the book class methods issueBook,
and returnBook.
* I convert the string answer into integers, using parse int().
* For Example:
* current Date = 06/11/25
* return Date = 07/02/25
* so I what is first used substring and removed out these dates 11 and 2.
* I have used absolute value, so even though result might be in negative but
absolute value makes it negative.
* 2+30=32
* |11-32|=21
* The book was borrowed for 21 days for total.
*/
public int browingDays() {
//declaring a book objects and assign book methods
Book b1 = new Book("Dummy Title", "Dummy Publisher", "Dummy
Author", 111, 2025, 200, true);
//declare and initialize variables
String dateGiven = b1.issueBook().substring(3, 5);
String dateAssigned = b1.returnBook().substring(3, 5);
int currentDate = Integer.parseInt(dateGiven);
int returnDate = Integer.parseInt(dateAssigned);
int days;
//calculate
returnDate+=30;
days = Math.abs(currentDate-returnDate);
//return value
return days;
}
// calls issue book
public void borrowBook() {
//declaring a book objects and assign book methods
Book b1 = new Book("Dummy Title", "Dummy Publisher", "Dummy
Author", 111, 2025, 200, true);
b1.issueBook();
}
// calls return book
public void returnBook1() {
//declaring a book objects and assign book methods
Book b1 = new Book("Dummy Title", "Dummy Publisher", "Dummy
Author", 111, 2025, 200, true);
b1.returnBook();
}
/*This method prints out everything perfectly.
* It is useful to keep things in order.
*/
public String toString() {
//return value
return "Customer[ID=" + id + ", Name=" + name + ", Email=" + email + ",
Phone=" + phone + "]";
}
}
returnBook
Late Penalty
Browning Days