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 cooperative throughout this project work. Through this column, it would be our utmost pleasure to express our warm thanks to her for their encouragement, cooperation 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;

String b. Book issued. id=b.String c.id=null. } public Book(String a. author=b.byte e) { name=a. price=d.float d. public Member(String a. } .author=null. id=null. } } class Member { String name=null. t=new Transaction(). total_copies=e.String b) { issued=null.0f. Transaction t. name=a. id=c. float fine=0. total_copies=issued=0.

month_of_return.print("Enter the month of issue:").out. short year_of_issue.out. } public void return_date()throws IOException .print("Enter the day of issue:").print("Enter the year of issue:").parseShort(b.parseByte(b.out.} class Transaction { byte day_of_issue.year_of_return.0f. month_of_issue=Byte. } public void issue_date()throws IOException { BufferedReader b=new BufferedReader(new InputStreamReader(System. System. byte day_of_return.parseByte(b. public Transaction() { day_of_issue=month_of_issue=1.month_of_issue. year_of_issue=Short.readLine()). System. year_of_return=2010. day_of_return=month_of_return=1. day_of_issue=Byte.in)). System. float fine=0.readLine()).readLine()). year_of_issue=2010.

i<month_of_return.readLine()).parseByte(b.out.print("Enter the year of return:").year_of_issue)-day_of_issue. } public short calc_days() { byte i. short days=0. System.{ BufferedReader b=new BufferedReader(new InputStreamReader(System.parseShort(b. year_of_return=Short. for(i=(byte)(month_of_issue+1). } else { days+=calc_no_of_days(month_of_issue. } . System.parseByte(b.out. System.in)).year_of_issue).print("Enter the day of return:").print("Enter the month of return:").out. month_of_return=Byte.readLine()). if(year_of_issue==year_of_return) { if(month_of_issue==month_of_return) { days=(short)(day_of_return-day_of_issue).readLine()). day_of_return=Byte.i++) { days+=calc_no_of_days(i.

i++) { days+=calc_no_of_days(i. else d=28.i<=12.year_of_issue). } public short calc_no_of_days(byte month. } days+=day_of_return. } } else { days+=calc_no_of_days(month_of_issue.i<month_of_return.i++) { days+=calc_no_of_days(i. } return days.short year) { short d=0.year_of_return).year_of_issue)-day_of_issue. switch(month) { case 2:if(year%4==0) d= 29. } for(i=1. for(i=(byte)(month_of_issue+1). case 1: .days+=day_of_return.

} public Object[] book_record() { . } return d. } } class Library { Vector books.y. members=new Vector(). Object[] x.members. case 4: case 6: case 9: case 11:d=30. update(). public Library() { books=new Vector().case 3: case 5: case 7: case 8: case 10: case 12:d=31.

books.String author.fine+= (m. } } public int find_book(String name.size()].String author) { .issued--.setElementAt(b.copyInto(x).t.Member m) { Book b=((Book)x[find_book(name.author)]).0f). } public void calc_fine(String name.return x.t.t.price.total_copies--.size()]. b. b.fine+=b. if(r.copyInto(y). y=new Object[members.calc_days()>7) { m. } public void update() { x=new Object[books.equalsIgnoreCase("y")) { m.t.calc_days())*(2.author)).String r. members. books.find_book(name. } else if(m.

if(x. } else { return -1.int pos_mem) { .length>0) { int i=0.equals(((Book)x[i]).length) { if(name. else return -1.author)) { flag=false. } if(!flag) return i. } } public void decrement(int pos_book.name) && author.boolean flag=true.equals(((Book)x[i]). while(flag && i<x. } else i++.

Member m=(Member)y[pos_mem]. Member m=(Member)y[pos_mem]. b.String id) { boolean flag=true. update().setElementAt(m.issued--. update().Book b=((Book)x[pos_book]). b.issued=b. if(x.pos_book).issued=null.total_copies--.String author.setElementAt(b.total_copies++. } public int find_book(String name. m. books. } public void increment(int pos_book.setElementAt(m. books. m.pos_mem). b.pos_book).pos_mem). b.int pos_mem) { Book b=((Book)x[pos_book]). members.setElementAt(b. members.issued++.length>0) .

} else i++.equals(((Book)x[i]). else return -1.id)) { flag=false.name) && author.equals(((Book)x[i]).author))|| id.length>0) . } else { return -1. if(y. } } public int find_member(String id) { boolean flag=true.length) { if((name.{ int i=0. } if(!flag) return i. while(flag && i<x.equals(((Book)x[i]).

id)) { flag=false. } if(!flag) return i.length) { if(id.in)). while(flag && i<y.equals(((Member)y[i]). else return -1. } else i++.{ int i=0. } } public void add_book()throws IOException { BufferedReader b=new BufferedReader(new InputStreamReader(System. . } else { return -1.

out.print("Enter the book id:").out.cop)).print("Enter name of the book:").readLine(). String id=b.out.print("Enter the name of the book to be deleted:").readLine()). . } } public void delete_book()throws IOException { BufferedReader b=new BufferedReader(new InputStreamReader(System.println("Added").print("Enter the price:"). String author=b.id)!=-1) { System. System. System.author. update().print("Enter the author's name:"). byte cop=Byte.readLine()).out. String name=b.parseFloat(b.readLine(). books.println("Either the book is already in the list or the ID has to be different").System.parseByte(b.id.addElement(new Book(name. } else { System. if(find_book(name.out. System. System.author.readLine(). float pr=Float.out.pr.print("Enter the number of copies:").out.out. System.in)).

out.readLine(). } update().println("The entered book is not there in the list at all.print("Enter the author's name of the book:").readLine().out. if(find_member(id)!=-1) { System.print("Enter your name:").removeElementAt(find_book(name. String id=b.out.print("Enter the id:"). } .readLine().author)).out."). if(find_book(name. System.author)!=-1) { books.String name=b. System.println("This ID is already given to another member"). } else { System. String name=b.out. System."). } public void add_member()throws IOException { BufferedReader b=new BufferedReader(new InputStreamReader(System.in)).out.println("Deleted. System.readLine(). String author=b.

println("Added").removeElementAt(find_member(id)). } } public void delete_member()throws IOException { BufferedReader b=new BufferedReader(new InputStreamReader(System. System. } else { System. System. update().addElement(new Member(name. } public void issue()throws IOException .println("The member is not there in the list at all").out. String id=b.id)).in)). if(find_member(id)!=-1) { members.out.out.else { members.out.print("Enter the member id:"). } update(). System.readLine().println("Terminated").

Member m=(Member)y[find_member(id)]. } else { System.readLine().out. System.print("Enter the author's name:").author)==-1 || ((Book)x[find_book(name.print("Enter the book name:").in)). if(find_book(name. .out. String name=b. } else if(((Member)y[find_member(id)]).println("You have already issued a book"). System.{ BufferedReader b=new BufferedReader(new InputStreamReader(System. String author=b.out.readLine().author). if(find_member(id)==-1) { System.readLine().issued!=null) { System. String id=b. } else { decrement(find_book(name.find_member(id)).out.println("Sorry.out.The book is not available").print("Enter the member id:").total_copies==2) { System.println("You are not a member of the library at all").author)]).out.

out. members.readLine(). Member m=(Member)y[find_member(id)].print("Have you lost the issued book?").find_member(id)). String id=b.m). System.author.out.m.in)). String r=b.equalsIgnoreCase("y")) { calc_fine(name. System. if(r. System. } else { .print("Enter the member ID:"). System. String author=b.setElementAt(m.readLine().r.t. } } } public void return_book()throws IOException { BufferedReader b=new BufferedReader(new InputStreamReader(System.find_member(id)).print("Enter the author name:").readLine(). members. update().print("Enter the book name:").issue_date().out.setElementAt(m.out.readLine(). String name=b.

t.out.author).print("Enter your id:").readLine()). update().setElementAt(m.m). if(find_member(id)!=-1) { Member m=(Member)y[find_member(id)]. update(). members.out.out.author. } System.println("Please enter the fine amount paid by the member:"). System.println("You are not a member of the library at all").r. . m. String id=b.println("Your fine is:"+m. System.setElementAt(m.return_date().find_member(id)).parseFloat(b. } public void receive_fine()throws IOException { BufferedReader b=new BufferedReader(new InputStreamReader(System.in)).issued=null. members. } else { System.t. calc_fine(name.m.find_member(id)). increment(find_book(name.out.fine).t.readLine().find_member(id)). m.fine-=Float.

println("4.in)). System. System.println().ADD A BOOK\n2.out.add_book(). break.println("7.ISSUE A BOOK\n6.} } } class Lib { public static void main(String[] a)throws IOException { Library l=new Library().ADD A MEMBER").out. System.println("1. System.readLine())) { case 1:l. break.RETURN A BOOK"). switch(Byte.TERMINATE A MEMBER\n5.out.DELETE A BOOK\n3.println("What do you want to do?"). do { System.out. case 2:l.ACCEPT FINE"). BufferedReader b=new BufferedReader(new InputStreamReader(System. .delete_book(). String resp.out.parseByte(b.

delete_member(). }while(resp. default:System. break.return_book().case 3:l.add_member(). case 4:l.receive_fine().issue().println(). break. } System. case 6:l. break.readLine(). break.print("Want to do any more operations?"). case 7:l. System. resp=b.println("Invalid choice"). case 5:l.out.out.equalsIgnoreCase("y")).out. break. } } /* OUTPUT: . break.

ADD A MEMBER 4.DELETE A BOOK 3.DELETE A BOOK 3.ACCEPT FINE 1 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.TERMINATE A MEMBER 5.ISSUE A BOOK 6.RETURN A BOOK 7.ACCEPT FINE .ADD A MEMBER 4.ADD A BOOK 2.RETURN A BOOK 7.TERMINATE A MEMBER 5.ISSUE A BOOK 6.ADD A BOOK 2.What do you want to do? 1.

ADD A BOOK 2.ACCEPT FINE 1 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 .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.RETURN A BOOK 7.DELETE A BOOK 3.ISSUE A BOOK 6.TERMINATE A MEMBER 5.ADD A MEMBER 4.

ADD A BOOK 2.ADD A MEMBER 4.ADD A MEMBER 4.RETURN A BOOK 7.DELETE A BOOK 3.ADD A BOOK 2.ISSUE A BOOK 6.DELETE A BOOK 3.ACCEPT FINE 1 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.ISSUE A BOOK 6.What do you want to do? 1.TERMINATE A MEMBER 5.RETURN A BOOK 7.ACCEPT FINE .TERMINATE A MEMBER 5.

ADD A BOOK 2.DELETE A BOOK 3.ADD A MEMBER 4.ACCEPT FINE 2 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 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.ISSUE A BOOK 6.RETURN A BOOK 7.TERMINATE A MEMBER 5.

ADD A BOOK 2.ISSUE A BOOK 6.TERMINATE A MEMBER 5.RETURN A BOOK 7.DELETE A BOOK 3.1.ADD A MEMBER 4.ADD A MEMBER 4.ACCEPT FINE 3 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.ISSUE A BOOK 6.TERMINATE A MEMBER 5.DELETE A BOOK 3.RETURN A BOOK 7.ACCEPT FINE 3 Enter your name:Arti Enter the id:M2 Added .

ACCEPT FINE .DELETE A BOOK 3.RETURN A BOOK 7.DELETE A BOOK 3.ACCEPT FINE 3 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.Want to do any more operations?y What do you want to do? 1.ISSUE A BOOK 6.ADD A MEMBER 4.ISSUE A BOOK 6.ADD A MEMBER 4.ADD A BOOK 2.TERMINATE A MEMBER 5.RETURN A BOOK 7.TERMINATE A MEMBER 5.

DELETE A BOOK 3.ADD A BOOK 2.ADD A MEMBER 4.RETURN A BOOK 7.ADD A MEMBER 4.ACCEPT FINE 3 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.ISSUE A BOOK 6.TERMINATE A MEMBER .TERMINATE A MEMBER 5.4 Enter the member id:M3 Terminated Want to do any more operations?y What do you want to do? 1.DELETE A BOOK 3.ADD A BOOK 2.

ACCEPT FINE 6 Enter the book name:App Chem Enter the author name:Jain Enter the member ID:M2 Have you lost the issued book?n .RETURN A BOOK 7.TERMINATE A MEMBER 5.ADD A BOOK 2.ADD A MEMBER 4.RETURN A BOOK 7.DELETE A BOOK 3.5.ISSUE A BOOK 6.ACCEPT FINE 5 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.ISSUE A BOOK 6.

0 Want to do any more operations?n .Enter the day of return:21 Enter the month of return:3 Enter the year of return:2008 Your fine is:0.

Sign up to vote on this title
UsefulNot useful