LIBRARY MANAGEMENT
ACKNOWLEDGEMENT
I sincerely thank Mrs.xyz, head of our Computer Depa Depart rtme ment nt and and our our lab lab assi assist stan antt Mrs. Mrs.xy xyz z for for thei their r support and guidance in completing the project in C++ on “LIBRARY MANAGEMMENT”, successfully. I also thank our principle, Dr.xyz for her kind support and the Scho School ol Boar Board d for for prov provid idin ing g us with with the the faci facili liti ties es for for doing the project.
2
TABLE OF CONTENTS Chapter Page •
•
•
•
•
•
SYSTEM Overview ………………………..………….. 5 SYSTEMS REQUIREMENTS SPECIFICATION Hardware and Software requirements ……………. 6 Problem Description ………………………………… 7 DESIGN SPECIFICATIONS File Design …………………………………………… 8 Procedural Design ………………………………….. 10 IMPLEMENTATION implementation with Program listing ……. 11 Program implementation Sample Outputs ……………………………………… 25 CONCLUSION Limits of the project …………………………………. 31 Future Extensions …………………………………… 32 REFERENCES …………………………………………. 33
3
SYSTEM OVERVIEW Library Management system can manage all the happenings of the Library. Book transactions including Book Registration, Stud Studen ents ts Regi Regist stra rati tion on,, Book Book Issu Issuin ing, g, Curr Curren entt Stat Status us of a part partic icul ular ar book books s etc. etc. can can be very very easi easily ly hand handle led d by this this module. Overall this system can be very helpful and it can make things easier 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.
4
HARDWARE AND SOFTWARE SPECIFICATION HARDWARE SPECIFICATION Server Nodes FDD CD drive Monitor Keyboard Mouse Printer
Intel® Pentium Pentium ® 4 CPU CPU 3.2 GHz , 256 MB RAM , 160 GB HDD Intel® Pentium Pentium ® 4 CPU CPU 3.2 GHz , 256 MB RAM , 80 GB HDD 1.44 Mb 52 X 14”SVGA 107 keys Optical mouse HP DJ 1125C 1125C , WIPRO 132 Col Dot Matrix Printer
SOFTWARE SPECIFICATION Network Operating System Software Operating Environment
Windows NT 4.0 TURBO C++ Ver 3.0 , MySQL 5.1 Windows XP Professional
5
PROBLEM DESCRIPTION Our project on developing a program to implement LIBRARY MANAGEMENT was encoded using C++ language The program is capable of performing the following tasks:
DATA SECURITY The data regarding books is password protected and the file can be opened only by librarian. ADDITION OF BOOKS It can feed the details about the book into the system and save it as a file. UPDATING BOOKS DETAILS It can change the details about the books any time. SEARCH A BOOK It can search for a book, if name of the book is provided. DELETING A BOOK It allows librarian to delete a book. •
•
•
•
•
The aim of this program is to fully automate the complete process of school of school library. library. Having taken into account a number of practical issues, it was felt the inclusion of the following features would be essential to make it user friendly. Menu •
6
•
Exit
FILE DESIGN Physical files: files: books.dat, user.dat. Logical files: fin, fout, file, fin2. Structure name: name: books, user. Structure variables: variables: book, u. Class name: name: librarian Objects: Objects: libobj. STRUCTURE books VARIABLE DATA TYPE
SIZE (b (bytes)
Code
Char
10
Name
Char
30
Author
Char
20
Price
Int
2
7
Status
Int
2
STRUCTURE user VARIABLE DATA TYPE
SIZE (bytes)
ucode
Char
10
bname
Char
30
uauthor
Char
20
bcode
Char
10
uprice
Int
2
CLASS Librarian DATA MEMBERS
DATA TYPE
SIZE (bytes)
Status
Char
10 8
PROCEDURAL DESIGN Void userpage(); Here the user-computer interface is handled. The user is allowed to issue a book, search for a book and view all the books available in the library.
Void libpage(); Here the librarian-computer interface is handled. The librarian is allowed to add, delete, modify, and view user details.
Void searchbook(); Here the function searches for the book in the file and reports to the user or librarian.
Void addbook(); Here the function allows the librarian to add new books to the already existing file.
Void delbook(); Here the function allows the librarian to delete a book from the file.
Void modify(); Here the function allows the librarian to update the details about the book like code, author’s name and price.
9
PROGRAM IMPLEMENTATION #include
#include #include #include #include #include #include #include #include //GLOBAL VARIABLES fstream file,fin,fout,fin2; file,fin,fout,fin2; void mainmenu(); struct books { char code[10]; char name[30]; char author[20]; int price; int status; }book; struct user { char ucode[10]; 10
char bcode[10]; char uname[30]; char uauthor[20]; int uprice; }u; class librarian { private: void update(); void password(); public: char status[10]; void display(); }libobj; void librarian::display() { clrscr(); fin.open("books.dat",ios::binary|ios::in); if(!fin) { cout<<"\nCan't open file!!!"; getch(); exit(0); } cout<<"\n\n"; cout<
11
cout<<"\n\n\n\n"; } fin.close(); getch(); }
void display() { cout<<"\n\n\n\n\n\n\n\n"; cout<
void displayuser() { cout<
12
void modify() { //LOCAL VARIABLES clrscr(); char cd[30],a[20],n[20],st; cd[30],a[20],n[20],st; float p; float np; cout<<"\n\n\n\n\tEnter cout<<"\n\n\n\n\tEnter the code you want to modify : "; cout<<"\n\n\t[* to keep the original name -1 for price] : "; char c[30]; gets(c); fstream f; f.open("BOOKS.DAT", ios::binary|ios::in|ios::o ios::binary|ios::in|ios::out); ut); while(f.read((char *)&book, sizeof(book))) { if(strcmp(book.code,c) == 0) { cout<<'\n'; cout<<"\n\n\n\tNew cout<<"\n\n\n\tNew Code :"; gets(cd); cout<<"\n\n\n\tNew cout<<"\n\n\n\tNew Name of book:"; gets(n); cout<<"\n\n\n\tNew cout<<"\n\n\n\tNew Author :"; gets(a); cout<<"\n\n\n\tNew cout<<"\n\n\n\tNew Price :";
13
cin>>p; cout<<"\n\n\n\tStatus :"; cin>>book.status; if(strcmp(cd,"*")!=0) strcpy(book.code,cd); if(strcmp(n,"*")!=0 ) strcpy(book.name,n); if(strcmp(a,"*")!=0) strcpy(book.author,a); if(p!=-1) book.price=p; f.seekp(f.tellg() - sizeof(book)); f.write((char *)&book, sizeof(book)); break; } } f.close(); }
void searchbook() { clrscr(); int k; char bname[30]; ofstream f; f.open("user.dat",ios::binary|ios::app); cout<<"\n\n\n\tEnter cout<<"\n\n\n\tEnter the name of the book:"; gets(bname); fin.open("books.dat",ios::binary|ios::in);
14
while(fin.read((char*)&book,sizeof(book))) { if(!fin) { cout<<"\nCan't open file!!!"; getch(); exit(0); } if(strcmp(bname,book.name)==0) { if(book.status==2) { cout<<"\n\n\tThe book is available...."; display(); cout<<"\n\n\n\tDo cout<<"\n\n\n\tDo you want to issue this book(y/n)? "; char c; cin>>c;
if(c=='y') { clrscr(); cout<<"\n\n\n\tEnter cout<<"\n\n\n\tEnter your code : "; cin>>u.ucode; strcpy(u.bcode,book.code); strcpy(u.uname,book.name); strcpy(u.uauthor,book.author); u.uprice=book.price; f.write((char *)&u,sizeof(u)); clrscr();
15
cout<<"\n\n\n\n\n\tYOUR cout<<"\n\n\n\n\n\tYOUR BOOK HAS BEEN ISSUED"; cout<<"\n\n\n\tTHANK cout<<"\n\n\n\tTHANK YOU!"; } }
else cout<<"\n\n\n\tSorry cout<<"\n\n\n\tSorry book already issued "; k=1; } } f.close();
if(k!=1) cout<<"\nThe book is currently not available...."; fin.close(); getch(); }
void userpage() { clrscr(); int ch,n=1; do {
16
cout<<"\n\n\n\n\tUSER cout<<"\n\n\n\n\tUSER MENU "; cout<<"\n\n\n\n\n\n\n\n\n\t[1] cout<<"\n\n\n\n\n\n\n\n\n\t[1] ISSUE A BOOK"; cout<<"\n\n\n\n\n\t[2] cout<<"\n\n\n\n\n\t[2] DISPLAY ALL BOOKS"; cout<<"\n\n\n\n\n\t[3] cout<<"\n\n\n\n\n\t[3] BACK TO MAIN"; gotoxy(10,35); cout<<"\n\n\n\n\n\tEnter cout<<"\n\n\n\n\n\tEnter your choice here ->> "; cin>>ch; switch(ch) {case 1:searchbook(); break; case 2:libobj.display(); break; case 3:mainmenu(); default:cout<<"\nWrong default:cout<<"\nWrong choice !!!\a"; } clrscr(); }while(n==1); }
void addbook() { char ch='y'; fout.open("books.dat",ios::binary|ios::app); if(!fout) {cout<<"\n\n\tCan't open file!!!"; getch(); exit(0); }
17
while(ch=='y'||ch=='Y') { clrscr(); cout<<"\n\n\n\n\tEnter cout<<"\n\n\n\n\tEnter the code : "; gets(book.code); cout<<"\n\n\n\n\tEnter cout<<"\n\n\n\n\tEnter the name of book : "; gets(book.name); cout<<"\n\n\n\n\tEnter cout<<"\n\n\n\n\tEnter the author : "; gets(book.author); cout<<"\n\n\n\n\tEnter cout<<"\n\n\n\n\tEnter the price : "; cin>>book.price; cout<<"\n\n\tEnter cout<<"\n\n\tEnter status(1 for for issue 2 for not issued) : "; cin>>book.status; fout.write((char*)&book,sizeof(book)); cout<<"\n\n\n\n\n\n\tDo cout<<"\n\n\n\n\n\n\tDo you want to continue?(y/n) : "; cin>>ch; } fout.close(); }
void delbook() { int fd=0; char cde[10]; clrscr(); cout<<"\n\n\n\n\tEnter cout<<"\n\n\n\n\tEnter code of of book to be deleted :: "; cin>>cde; fin.open("books.dat",ios::binary|ios::in|ios::app); fin2.open("temp.dat",ios::binary|ios::out|ios::app); while(fin.read((char*)&book,sizeof(book))) { if(strcmp(cde,book.code if(strcmp(cde,book.code)!=0) )!=0)
18
fin2.write((char*)&book,sizeof(book)); } fin.close(); fin2.close(); remove("books.dat"); rename("temp.dat","books.dat"); cout<<"\n\n\n\n\tBook cout<<"\n\n\n\n\tBook deleted "; getch(); }
void userd() { char c[10],fd=0; ifstream f; f.open("user.dat",ios::binary|ios::in); clrscr(); cout<<"\n\n Enter the code of the user you want to see : "; gets(c); cout<<"\n\n\n\n\n\n\n\n"; cout<
19
} } getch(); if (fd==0) cout<<"\n\n Such user does not exist !\a"; getch(); f.close(); }
void libpage() { char pwd[8]; int l=0,ch,n=1,i; clrscr(); pt: gotoxy(20,20); cout<<"ENTER THE PASSWORD(8 characters):: "; l++; for(i=0;i<8;i++) { pwd[i]=getch(); cout<<"*"; } getch(); pwd[8]='\0'; if(strcmp(pwd,"password")==0) { cout<<"\nWELCOME"; cout<<"\nWELCOME"; } else if(l==3)
20
exit(0); else { cout<<"\n\n\t\t cout<<"\n\n\t\t WRONG PASSWORD!!!\a"; getch(); clrscr(); goto pt; } clrscr(); do { cout<<"\n\n\n\n\n\t cout<<"\n\n\n\n\n\t LIBRARY MENU "; cout<<"\n\n\n\n\n\t cout<<"\n\n\n\n\n\t [1] Add a book"; cout<<"\n\n\n\n\n\t cout<<"\n\n\n\n\n\t [2] Delete a book"; cout<<"\n\n\n\n\n\t cout<<"\n\n\n\n\n\t [3] Update Book"; cout<<"\n\n\n\n\n\t cout<<"\n\n\n\n\n\t [4] View user details"; cout<<"\n\n\n\n\n\t cout<<"\n\n\n\n\n\t [5] View all books"; cout<<"\n\n\n\n\n\t cout<<"\n\n\n\n\n\t [6] Main menu"; gotoxy(10,40); cout<<"Enter your choice here ->> "; cin>>ch;
switch(ch) {case 1:addbook(); break; case 2:delbook(); break; case 3:modify(); break; case 4:userd(); break; case 5:libobj.display(); break; case 6:mainmenu();
21
break; default:cout<<"\nWrong default:cout<<"\nWrong choice !!!"; } clrscr(); }while(n==1); }
void final() { clrscr(); gotoxy(25,20); cout<<"\n\n\n }
T H A N K Y O U ! ";
void mainmenu() { int op; char ch='y'; do { clrscr(); time_t rawtime; time(&rawtime); cout<<"\n\n\n\n"; printf ("\n\n\n\t TIME:: %s", ctime (&rawtime) ); cout<<"\n\n\n\n\n\t\tM cout<<"\n\n\n\n\n\t\tM A I N M E N U\n\n\n\n\n"; cout<<"\t[1] USER\n\n\n\n\n"; USER\n\n\n\n\n"; cout<<"\t[2] LIBRARIAN\n\n\n\n\n"; LIBRARIAN\n\n\n\n\n"; cout<<"\t[3] EXIT\n\n\n\n\n"; EXIT\n\n\n\n\n";
22
gotoxy(10,40); cout<<"Enter your choice here -->>"; cin>>op; switch(op) { case 1:userpage(); break; case 2:libpage(); break; case 3:final(); getch(); exit(0); break; default:cout<<"\nINVALID default:cout<<"\nINVALID OPTION...!!!\a\n"; OPTION...!!!\a\n"; } }while(ch=='y'||ch=='Y'); } void main() { clrscr(); gotoxy(20,20); cout<<"\n\n\n A B C PUBLIC SCHOOL LIBRARY "; cout<<" \n ___________________________ _____________________________________"; __________"; getch(); mainmenu(); getch(); }
23
SCREEN SHOTS
24
25
26
27
28
29
30
LIMITS OF THE PROJECT The
password cannot be changed within the program
The
program will accept two books having the same code.
Since
the display is restricted to a single screen, too many books cannot be accommodated.
31
FUTURE EXTENSIONS A
more attractive, user user friendly and compact compact interface is planned.
Provision
for individual profile and accounts for users with password protection.
A
more diverse classification classification of books, based on languages.
Error
- auto correcting capable inputs at all stages.
32
REFERENCES Computer
science with C++: class XI By Sumita Arora
Computer
science with C++: class XII By Sumita Arora
33