Vous êtes sur la page 1sur 29

Library Management System

UNDER THE GUIDANCE OF

Ms Komal

Submitted to :- MS KOMAL

Submitted By: - Sahil Salgotra

Reg no: 1050070184

ACKNOWLEDGEMENT
We are extremely grateful and remain indebted to our guide Ms Komal
for being a source of inspiration and for his constant support in the Design,
Implementation and Evaluation of the project. We are thankful to her for the
constant constructive criticism and invaluable suggestions, which benefited us a lot
while developing the project on “LIBRARY MANAGEMENT”. She has been a
constant source of inspiration and motivation for hard work. She has been very co-
operative throughout this project work. Through this column, it would be our
utmost pleasure to express our warm thanks to her for their encouragement, co-
operation and consent without which we mightn’t be able to accomplish this
project.

SAHIL SALGOTRA
PREFACE
This project of “ LIBRARY MANAGEMENT” gives us the complete information
about the library. We can enter the record of new books and retrieve the details of books
available in the library. We can issue the books to the students and maintain their records and can
also check how many books are issued and stock available in the library. In this project we can
maintain the late fine of students who returns the issued books after the due date.

Throughout the project the focus has been on presenting information and comments in
an easy and intelligible manner. The project is very useful for those who want to know about
Library Management System.

PROCESS DESCRIPTION

The Library Management System is designed & developed for a receipt and issuance of
books in the library along with the student’s details. The books received in the library are entered
in Books Entry form and the new student is entered in the student entry form. When the student
wants to get the desired book the same is issued on the availability basis to the student. The
issuance and due date for the returning of the book is also entered into the Book Issue form under
third menu Book Issue. The student has to pay the fine if any on the basis of no. of days delayed
deposit of the book in the library.

Program
import java.io.*;

import java.util.Vector;

class Book

String name,author,id;

float price;

byte total_copies,issued;

public Book()

name=null;
author=null;

id=null;

total_copies=issued=0;

public Book(String a,String b,String c,float d,byte e)

name=a;

author=b;

id=c;

price=d;

total_copies=e;

class Member

String name=null,id=null;

Transaction t;

Book issued;

float fine=0.0f;

public Member(String a,String b)

issued=null;

t=new Transaction();

name=a;

id=b;

}
}

class Transaction

byte day_of_issue,month_of_issue;

byte day_of_return,month_of_return;

short year_of_issue,year_of_return;

float fine=0.0f;

public Transaction()

day_of_issue=month_of_issue=1;

year_of_issue=2010;

day_of_return=month_of_return=1;

year_of_return=2010;

public void issue_date()throws IOException

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the day of issue:");

day_of_issue=Byte.parseByte(b.readLine());

System.out.print("Enter the month of issue:");

month_of_issue=Byte.parseByte(b.readLine());

System.out.print("Enter the year of issue:");

year_of_issue=Short.parseShort(b.readLine());

public void return_date()throws IOException


{

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the day of return:");

day_of_return=Byte.parseByte(b.readLine());

System.out.print("Enter the month of return:");

month_of_return=Byte.parseByte(b.readLine());

System.out.print("Enter the year of return:");

year_of_return=Short.parseShort(b.readLine());

public short calc_days()

byte i;

short days=0;

if(year_of_issue==year_of_return)

if(month_of_issue==month_of_return)

days=(short)(day_of_return-day_of_issue);

else

days+=calc_no_of_days(month_of_issue,year_of_issue)-day_of_issue;

for(i=(byte)(month_of_issue+1);i<month_of_return;i++)

days+=calc_no_of_days(i,year_of_issue);

}
days+=day_of_return;

else

days+=calc_no_of_days(month_of_issue,year_of_issue)-day_of_issue;

for(i=(byte)(month_of_issue+1);i<=12;i++)

days+=calc_no_of_days(i,year_of_issue);

for(i=1;i<month_of_return;i++)

days+=calc_no_of_days(i,year_of_return);

days+=day_of_return;

return days;

public short calc_no_of_days(byte month,short year)

short d=0;

switch(month)

case 2:if(year%4==0) d= 29;

else d=28;

case 1:
case 3:

case 5:

case 7:

case 8:

case 10:

case 12:d=31;

case 4:

case 6:

case 9:

case 11:d=30;

return d;

class Library

Vector books,members;

Object[] x,y;

public Library()

books=new Vector();

members=new Vector();

update();

public Object[] book_record()

{
return x;

public void update()

x=new Object[books.size()];

books.copyInto(x);

y=new Object[members.size()];

members.copyInto(y);

public void calc_fine(String name,String author,String r,Member m)

Book b=((Book)x[find_book(name,author)]);

if(r.equalsIgnoreCase("y"))

m.t.fine+=b.price;

b.total_copies--;

b.issued--;

books.setElementAt(b,find_book(name,author));

else if(m.t.calc_days()>7)

m.t.fine+= (m.t.calc_days())*(2.0f);

public int find_book(String name,String author)

{
boolean flag=true;

if(x.length>0)

int i=0;

while(flag && i<x.length)

if(name.equals(((Book)x[i]).name) && author.equals(((Book)x[i]).author))

flag=false;

else

i++;

if(!flag)

return i;

else

return -1;

else

return -1;

public void decrement(int pos_book,int pos_mem)

{
Book b=((Book)x[pos_book]);

b.total_copies--;

b.issued++;

books.setElementAt(b,pos_book);

Member m=(Member)y[pos_mem];

m.issued=null;

members.setElementAt(m,pos_mem);

update();

public void increment(int pos_book,int pos_mem)

Book b=((Book)x[pos_book]);

b.total_copies++;

b.issued--;

books.setElementAt(b,pos_book);

Member m=(Member)y[pos_mem];

m.issued=b;

members.setElementAt(m,pos_mem);

update();

public int find_book(String name,String author,String id)

boolean flag=true;

if(x.length>0)
{

int i=0;

while(flag && i<x.length)

if((name.equals(((Book)x[i]).name) && author.equals(((Book)x[i]).author))||


id.equals(((Book)x[i]).id))

flag=false;

else

i++;

if(!flag)

return i;

else

return -1;

else

return -1;

public int find_member(String id)

boolean flag=true;

if(y.length>0)
{

int i=0;

while(flag && i<y.length)

if(id.equals(((Member)y[i]).id))

flag=false;

else

i++;

if(!flag)

return i;

else

return -1;

else

return -1;

public void add_book()throws IOException

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));


System.out.print("Enter name of the book:");

String name=b.readLine();

System.out.print("Enter the author's name:");

String author=b.readLine();

System.out.print("Enter the book id:");

String id=b.readLine();

if(find_book(name,author,id)!=-1)

System.out.println("Either the book is already in the list or the ID has to be


different");

else

System.out.print("Enter the price:");

float pr=Float.parseFloat(b.readLine());

System.out.print("Enter the number of copies:");

byte cop=Byte.parseByte(b.readLine());

books.addElement(new Book(name,author,id,pr,cop));

System.out.println("Added");

update();

public void delete_book()throws IOException

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the name of the book to be deleted:");


String name=b.readLine();

System.out.print("Enter the author's name of the book:");

String author=b.readLine();

if(find_book(name,author)!=-1)

books.removeElementAt(find_book(name,author));

System.out.println("Deleted.");

else

System.out.println("The entered book is not there in the list at all.");

update();

public void add_member()throws IOException

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter your name:");

String name=b.readLine();

System.out.print("Enter the id:");

String id=b.readLine();

if(find_member(id)!=-1)

System.out.println("This ID is already given to another member");

}
else

members.addElement(new Member(name,id));

System.out.println("Added");

update();

public void delete_member()throws IOException

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the member id:");

String id=b.readLine();

if(find_member(id)!=-1)

members.removeElementAt(find_member(id));

System.out.println("Terminated");

else

System.out.println("The member is not there in the list at all");

update();

public void issue()throws IOException


{

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the member id:");

String id=b.readLine();

if(find_member(id)==-1)

System.out.println("You are not a member of the library at all");

else

System.out.print("Enter the book name:");

String name=b.readLine();

System.out.print("Enter the author's name:");

String author=b.readLine();

if(find_book(name,author)==-1 ||
((Book)x[find_book(name,author)]).total_copies==2)

System.out.println("Sorry.The book is not available");

else if(((Member)y[find_member(id)]).issued!=null)

System.out.println("You have already issued a book");

else

decrement(find_book(name,author),find_member(id));

Member m=(Member)y[find_member(id)];
m.t.issue_date();

members.setElementAt(m,find_member(id));

update();

public void return_book()throws IOException

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter the book name:");

String name=b.readLine();

System.out.print("Enter the author name:");

String author=b.readLine();

System.out.print("Enter the member ID:");

String id=b.readLine();

Member m=(Member)y[find_member(id)];

System.out.print("Have you lost the issued book?");

String r=b.readLine();

if(r.equalsIgnoreCase("y"))

calc_fine(name,author,r,m);

members.setElementAt(m,find_member(id));

else

{
m.t.return_date();

calc_fine(name,author,r,m);

members.setElementAt(m,find_member(id));

increment(find_book(name,author),find_member(id));

System.out.println("Your fine is:"+m.t.fine);

update();

public void receive_fine()throws IOException

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

System.out.print("Enter your id:");

String id=b.readLine();

if(find_member(id)!=-1)

Member m=(Member)y[find_member(id)];

System.out.println("Please enter the fine amount paid by the member:");

m.t.fine-=Float.parseFloat(b.readLine());

m.issued=null;

members.setElementAt(m,find_member(id));

update();

else

System.out.println("You are not a member of the library at all");


}

class Lib

public static void main(String[] a)throws IOException

Library l=new Library();

String resp;

BufferedReader b=new BufferedReader(new InputStreamReader(System.in));

do

System.out.println();

System.out.println("What do you want to do?");

System.out.println("1.ADD A BOOK\n2.DELETE A BOOK\n3.ADD A MEMBER");

System.out.println("4.TERMINATE A MEMBER\n5.ISSUE A BOOK\n6.RETURN A


BOOK");

System.out.println("7.ACCEPT FINE");

switch(Byte.parseByte(b.readLine()))

case 1:l.add_book();

break;

case 2:l.delete_book();

break;
case 3:l.add_member();

break;

case 4:l.delete_member();

break;

case 5:l.issue();

break;

case 6:l.return_book();

break;

case 7:l.receive_fine();

break;

default:System.out.println("Invalid choice");

break;

System.out.println();

System.out.print("Want to do any more operations?");

resp=b.readLine();

}while(resp.equalsIgnoreCase("y"));

/*

OUTPUT:
What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter name of the book:App Chem

Enter the author's name:Jain

Enter the book id:B1

Enter the price:120

Enter the number of copies:12

Added

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE
1

Enter name of the book: java

Enter the author's name: Kumbojkar

Enter the book id:B2

Enter the price:130

Enter the number of copies:11

Added

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter name of the book: App Phy

Enter the author's name: Nandu

Enter the book id:B2

Either the book is already in the list or the ID has to be different

Want to do any more operations?y


What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter name of the book:App Phy

Enter the author's name:Nandu

Enter the book id:B3

Enter the price:140

Enter the number of copies:20

Added

Want to do any more operations? y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE
1

Enter name of the book:Comp Prog

Enter the author's name:Herbett

Enter the book id:B4

Enter the price:129

Enter the number of copies:14

Added

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter the name of the book to be deleted:App Phy

Enter the author's name of the book:Nandu

Deleted.

Want to do any more operations?y

What do you want to do?


1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter your name:Arvind

Enter the id:M1

Added

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter your name:Arti

Enter the id:M2

Added
Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter your name:Karthik

Enter the id:M3

Added

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE
4

Enter the member id:M3

Terminated

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter your name:Karthik

Enter the id:M2

This ID is already given to another member

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER
5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter the member id:M2

Enter the book name:App Chem

Enter the author's name:Jain

Enter the day of issue:16

Enter the month of issue:3

Enter the year of issue:2008

Want to do any more operations?y

What do you want to do?

1.ADD A BOOK

2.DELETE A BOOK

3.ADD A MEMBER

4.TERMINATE A MEMBER

5.ISSUE A BOOK

6.RETURN A BOOK

7.ACCEPT FINE

Enter the book name:App Chem

Enter the author name:Jain

Enter the member ID:M2

Have you lost the issued book?n


Enter the day of return:21

Enter the month of return:3

Enter the year of return:2008

Your fine is:0.0

Want to do any more operations?n

Vous aimerez peut-être aussi