You are on page 1of 3

BlueJ Project on Library Management

This project is on library management. Books are issued to students from library.
Details of the students like Name of the student, class in which he/she reads, Regd.
No, section, issue and return date of the book are kept in record along with the book
name, author of the book and price of the book.

For delay of returning the book, a fine is imposed on students according to the
following:

First 7 days: Fine 0


Next 8 days: Fine Rs. 2 per day
Next 15 days: Fine Rs. 3.50 per day
Above 30 days: Rs. 5.50 per day + price of the book

The program deals with the above library management.

Program

import java.io.*;
class Library
{
String name, regd_no,cl,sec,book,author,issue,ret;
double fine,price;
int datediff;
String s1,s2;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
public void take() throws IOException
{
System.out.println("Enter Student Name:");
name=br.readLine();
System.out.println("Enter Student Regd. No:");
regd_no=br.readLine();
System.out.println("Enter Class:");
cl=br.readLine();
System.out.println("Enter Section:");
sec=br.readLine();
System.out.println("Enter Name of the Book issue:");
book=br.readLine();
System.out.println("Enter Author Name of the Book:");
author=br.readLine();
System.out.println("Enter Date of Issue of the Book (dd/mm/yyyy):");
issue=br.readLine();
System.out.println("Enter Date of Return of the Book (dd/mm/yyyy):");
ret=br.readLine();
s1=issue;
s2=ret;
diff();
}
private void diff()
{
int d,d1,m,m1,y,y1;
d1=0;
d=0;
m1=0;m=0;
int i,x=0;
datediff=0;
while(true)
{
i=issue.indexOf("/");
if (i<0 o:p="">
break;
if(x==0)
{
d=Integer.parseInt(issue.substring(0,i));
issue=issue.substring(i+1);
}
else if(x==1)
{
m=Integer.parseInt(issue.substring(0,i));
issue=issue.substring(i+1);
}
x++;
}
y=Integer.parseInt(issue);
x=0;
while(true)
{
i=ret.indexOf("/");
if (i<0 o:p="">
break;
if(x==0)
{
d1=Integer.parseInt(ret.substring(0,i));
ret=ret.substring(i+1);
}
else if(x==1)
{
m1=Integer.parseInt(ret.substring(0,i));
ret=ret.substring(i+1);
}
x++;
}
y1=Integer.parseInt(ret);
m1=m1+(12*(y1-y));
if(m1-m>2)
datediff=31;
// date diff is more than 30
else if(m1-m>1)
datediff=d1+30-d;
else
datediff=d1-d;
fine();
}
private void fine()
{
if(datediff<=7)
fine=0;
else if(datediff<=15)
fine=2*datediff;
else if(datediff<=30)
fine=3.5*datediff;
else
fine=fine+5.5*datediff;
show();
}
private void show()
{
System.out.println("Name of the student:"+name);
System.out.println("Regd No of the student:"+regd_no);
System.out.println("Class of the student:"+cl);
System.out.println("Section of the student:"+sec);
System.out.println("Book issue to the student:"+book);
System.out.println("Author of the Book:"+author);
System.out.println("Book issue on:"+s1);
System.out.println("Return Date of the Book:"+s2);
System.out.println("Fine Amount:"+fine);
}
}
}

You might also like