Вы находитесь на странице: 1из 33

LIBRARY MANAGEMENT

ACKNOWLEDGEMENT
I sincerely thank Mrs.xyz, head of our Computer Department and our lab assistant Mrs.xyz for their 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 School Board for providing us with the facilities for doing the project.

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 Program implementation with Program listing . 11 Sample Outputs 25 CONCLUSION Limits of the project . 31 Future Extensions 32 REFERENCES . 33

SYSTEM OVERVIEW
Library Management system can manage all the happenings of the Library. Book transactions including Book Registration, Students Registration, Book Issuing, Current Status of a particular books etc. can be very easily handled by 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 students 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.

HARDWARE AND SOFTWARE SPECIFICATION


HARDWARE SPECIFICATION Server Nodes FDD CD drive Monitor Keyboard Mouse Printer Intel Pentium 4 CPU 3.2 GHz , 256 MB RAM , 160 GB HDD Intel Pentium 4 CPU 3.2 GHz , 256 MB RAM , 80 GB HDD 1.44 Mb 52 X 14SVGA 107 keys Optical mouse HP DJ 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

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 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: books.dat, user.dat. Logical files: fin, fout, file, fin2. Structure name: books, user. Structure variables: book, u. Class name: librarian Objects: libobj. STRUCTURE books VARIABLE DATA TYPE Code Name Author Price Char Char Char Int SIZE (bytes) 10 30 20 2

Status

Int

STRUCTURE user VARIABLE DATA TYPE ucode bname uauthor bcode uprice Char Char Char Char Int SIZE (bytes) 10 30 20 10 2

CLASS Librarian DATA MEMBERS Status DATA TYPE Char


8

SIZE (bytes) 10

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, authors name and price.

PROGRAM IMPLEMENTATION
#include<fstream.h> #include<conio.h> #include<stdlib.h> #include<iomanip.h> #include<process.h> #include<stdio.h> #include<string.h> #include<time.h> #include<iostream.h> //GLOBAL VARIABLES fstream 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<<setw(10)<<"CODE"<<setw(20)<<"NAME"; cout<<setw(20)<<"AUTHOR"; cout<<setw(20)<<"PRICE"; cout<<"\n___________________________________"; cout<<"\n\n\n\n\n\n"; while(fin.read((char*)&book,sizeof(book))) { cout<<setw(10)<<book.code<<setw(20)<<book.name; cout<<setw(20)<<book.author; cout<<setw(20)<<book.price;
11

cout<<"\n\n\n\n"; } fin.close(); getch(); }

void display() { cout<<"\n\n\n\n\n\n\n\n"; cout<<setw(10)<<"CODE"<<setw(20)<<"NAME"; cout<<setw(20)<<"AUTHOR"; cout<<setw(20)<<"PRICE"; cout<<"\n __________________________________"; cout<<"\n\n\n\n\n\n"; cout<<setw(10)<<book.code<<setw(20)<<book.name; cout<<setw(20); cout<<book.author<<setw(20)<<book.price; cout<<"\n\n\n\n"; }

void displayuser() { cout<<setw(10)<<u.bcode<<setw(20)<<u.uname; cout<<setw(20)<<u.uauthor; cout<<setw(20)<<u.uprice; cout<<"\n\n\n\n"; }

12

void modify() { //LOCAL VARIABLES clrscr(); char cd[30],a[20],n[20],st; float p; float np; 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::out); while(f.read((char *)&book, sizeof(book))) { if(strcmp(book.code,c) == 0) { cout<<'\n'; cout<<"\n\n\n\tNew Code :"; gets(cd); cout<<"\n\n\n\tNew Name of book:"; gets(n); cout<<"\n\n\n\tNew Author :"; gets(a); 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 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 you want to issue this book(y/n)? "; char c; cin>>c; if(c=='y') { clrscr(); 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 BOOK HAS BEEN ISSUED"; cout<<"\n\n\n\tTHANK YOU!"; } }

else 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 MENU "; cout<<"\n\n\n\n\n\n\n\n\n\t[1] ISSUE A BOOK"; cout<<"\n\n\n\n\n\t[2] DISPLAY ALL BOOKS"; cout<<"\n\n\n\n\n\t[3] BACK TO MAIN"; gotoxy(10,35); 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 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 the code : "; gets(book.code); cout<<"\n\n\n\n\tEnter the name of book : "; gets(book.name); cout<<"\n\n\n\n\tEnter the author : "; gets(book.author); cout<<"\n\n\n\n\tEnter the price : "; cin>>book.price; cout<<"\n\n\tEnter status(1 for issue 2 for not issued) : "; cin>>book.status; fout.write((char*)&book,sizeof(book)); 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 code 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)!=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 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<<setw(10)<<"CODE"<<setw(20)<<"NAME"; cout<<setw(20)<<"AUTHOR"; cout<<setw(20)<<"PRICE"; cout<<"\n__________________________________"; cout<<"\n\n\n\n\n\n"; while(f.read((char*)&u,sizeof(u))) { if(strcmp(u.ucode,c)==0) {displayuser(); fd=1;
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"; } else if(l==3)
20

exit(0); else { cout<<"\n\n\t\t WRONG PASSWORD!!!\a"; getch(); clrscr(); goto pt; } clrscr(); do { cout<<"\n\n\n\n\n\t LIBRARY MENU "; cout<<"\n\n\n\n\n\t [1] Add a book"; cout<<"\n\n\n\n\n\t [2] Delete a book"; cout<<"\n\n\n\n\n\t [3] Update Book"; cout<<"\n\n\n\n\n\t [4] View user details"; cout<<"\n\n\n\n\n\t [5] View all books"; 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 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 A I N M E N U\n\n\n\n\n"; cout<<"\t[1] USER\n\n\n\n\n"; cout<<"\t[2] LIBRARIAN\n\n\n\n\n"; cout<<"\t[3] 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 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 friendly and compact interface is planned. Provision for individual profile and accounts for users with password protection. A more diverse 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

Вам также может понравиться