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

KENDRIYA VIDYALAYA

FAIZABAD CANTT

Academic year
......2018-2019……
COMPUTER SCIENCE PROJECT WORK | LIBRARY MANAGEMENT SYSTEM
PAGE 1
“LIBRARY MANAGEMENT SYSTEM”
SUBMITTED by: HEMANT UPADHYAY
Class: XII-SCIENCE
Roll no. :_____________
Submitted to: S. S. PALIYA

PAGE 2
1. Acknowledgement
2. CERTIFICATE
3. Header FILES USED
4. Working description
5. Coding
6. Bibliography

PAGE 3
“There are times when silence speaks so much more loudly than
words of praise to only as good as scorn a person, whose word
do not express, but only put a veneer over true feelings, which
are of gratitude at this point of time.”

I sincerely extend my deepest gratitude to our principal


“Shri Amit Srivastava” for providing us with all the facilities
and kind moral support for carrying out this project work.
I take this opportunity to give my special thanks to our esteemed
computer science teacher “Shri S. S. Paliya” for his inevitable
help, guidance and encouragement, without which this project
would not have come forth.

PAGE 4
Secondly, I would also like to thank my parents and friends who
helped me a lot in finalizing this project within the limited time
frame.

This is to certify that HEMANT UPAHYAY, a


student of class XII-SCIENCE has successfully
completed the research on the project
LIBRARY MANAGEMENT SYSTEM
under the guidance of
MR. S. S. Paliya (Subject Teacher) during the
year 2018-19 in partial fulfilment of physics
practical examination conducted by CBSE.

PAGE 5
(Examiner Signature) (TEACHER)

In order to run program these header files should have to be


included or an error will show on compiling “this function
should have a prototype”
1. fstream.h
2. conio.h
3. stdio.h
4. process.h
5. string.h
6. iomanip.h

PAGE 6
This program is designed to keep the record of library
like number of books, which books are issued or which
are not, record of a book etc.
This program consists of 11 options
1. CREATE STUDENT RECORD
2. DISPLAY ALL STUDENTS RECORD
3. DISPLAY SPECIFIC STUDENT RECORD
4. MODIFY STUDENT RECORD
5. DELETE STUDENT RECORD
6. CREATE BOOK
7. DISPLAY ALL BOOKS
8. DISPLAY SPECIFIC BOOK
9. MODIFY BOOK
10. DELETE BOOK
11. BACK TO MAIN MENU

PAGE 7
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<iomanip.h>

//*****************************************
**********************
// CLASSES USED IN PROJECT
//*****************************************
***********************

class book{
char book_number[6];
char book_name[50]; //title of book

PAGE 8
char author_name[20]; //author of
book
public:
void create_book()
{
cout<<"\nNEW BOOK ENTRY...\n";
cout<< "\nEnter Book Number : ";
cin>>book_number;
cout<< "\nEnter Name of the Book : ";
gets(book_name);
cout<<"\nEnter Author's name : ";
gets(author_name);
cout<<"\n\nBook Created...";
}

void show_book()
{
cout<<"\nBook number : " << book_number;
cout<<"\nBook Name : ";
puts(book_name);
cout<<"Author Name : ";
puts(author_name);
}

void modify_book()

PAGE 9
{
cout<<"\nBook number : " << book_number;
cout<<"\nModify Book Name : ";
gets(book_name);
cout<<"\nModify Author's Name : ";
gets(author_name);
}

char* retbook_number(){ return book_number; }

void report()
{
cout<<book_number<<setw(30)<<book_name<<set
w(30)
<<author_name<<endl;
}

}; //end of class book

class student
{
private:
char admno[6]; //Admission number

PAGE 10
char name[20]; //Name of the
student
char stbook_number[6]; //Student Book
number
int token;
public:
void create_student()
{
clrscr();
cout<<"\nNEW STUDENT
ENTRY...\n";
cout<<"\nEnter Admission number : ";
cin>>admno;
cout << "\nEnter Name of Student : ";
gets(name);
token = 0;
stbook_number[0] = '\0';
cout<<"\n\nStudent Record Created..";}

void show_student()
{
cout<<"\nAdmission number : "<<admno;
cout<<"\nStudent Name : ";
puts(name);

PAGE 11
cout<<"\nNumber of Book(s) issued :
"<<token;
if( token == 1 )
cout<<"\nBook No "<<stbook_number;
}

void modify_student()
{
cout<<"\nAdmission number : "<<admno;
cout<<"\nModify Student Name : ";
gets(name);
}

char* retadmno(){ return admno ; }

char* retstbook_number(){ return


stbook_number ; }

int rettoken(){ return token ; }

void addtoken(){ token = 1; }

void resettoken(){ token = 0; }

PAGE 12
void getstbook_number(char
t[]){ strcpy(stbook_number,t); }

void report()
{cout
<<"\t"<<admno<<setw(20)<<name<<setw(10)<<to
ken<<endl;}

}; //end of class student

//*****************************************
*************************
// Global declaration for stream object of book,
object of student
//*****************************************
*************************

fstream fio, fio1;


book book1;
student stud;

PAGE 13
//*****************************************
**********************
// Functions to write record to file
//*****************************************
***********************

void write_book()
{
char ch;
fio.open("book.dat", ios::out|ios::app);
do{
clrscr();
book1.create_book();
fio.write((char*)&book1, sizeof(book));
cout<<"\n\nDo you want to add more
books...(y/n?)";
cin>>ch;
}while( ch == 'y'|| ch == 'Y' );
fio.close();
}

void write_student()
{
char ch;
fio.open("student.dat", ios::out|ios::app);

PAGE 14
do{
stud.create_student();
fio.write((char*)&stud,sizeof(student));
cout<<"\n\nDo you want to add more
students...(y/n?)";
cin>>ch;
}while(ch=='y'||ch=='Y');
fio.close();
}

//*****************************************
**********************
// Function to read specific record from file
//*****************************************
***********************

void display_specific_book(char n[])


{
cout<<"\nBOOK DETAILS\n";

PAGE 15
int flag = 0;
fio.open("book.dat", ios::in);
while(fio.read((char*)&book1, sizeof(book)))
{
if( strcmpi(book1.retbook_number(),n) == 0 ){
book1.show_book();
flag = 1;}
}

fio.close();
if(flag==0) cout<<"\n\nBook does not exist";
getch();
}

void display_specific_student(char n[])


{
cout<<"\nSTUDENT DETAILS\n";
int flag = 0;
fio.open("student.dat", ios::in);
while(fio.read((char*)&stud, sizeof(student)))
{
if((strcmpi(stud.retadmno(),n)==0))
{
stud.show_student();
flag = 1;

PAGE 16
}
}
fio.close();
if( flag == 0 ) cout<<"\n\nStudent does not exist";
getch();
}

//*****************************************
**********************
// Functions to modify records of file
//*****************************************
***********************

void modify_book()
{
char n[6];
int found = 0;
clrscr();
cout<<"\n\n\tMODIFY BOOK REOCORD.... ";
cout<<"\n\n\tEnter The book no. of The book";
cin>>n;

PAGE 17
fio.open("book.dat", ios::in|ios::out);
while(fio.read((char*)&book1, sizeof(book)) &&
found == 0){
if(strcmpi(book1.retbook_number(),n) == 0){
book1.show_book();
cout<<"\nEnter New Details of
Book"<<endl;
book1.modify_book();
int pos = -1 * sizeof(book1);
fio.seekp(pos,ios::cur);
fio.write((char*)&book1, sizeof(book));
cout<<"\n\n\t Record Updated";
found = 1;
}
}

fio.close();
if( found == 0 ) cout<<"\n\n Record Not Found ";
getch();
}

void modify_student_name()
{
char n[6];

PAGE 18
int found = 0;
clrscr();
cout<<"\n\n\tMODIFY STUDENT RECORD... ";
cout<<"\n\n\tEnter Admission number of
Student";
cin >> n;
fio.open("student.dat", ios::in|ios::out);
while( fio.read((char*)&stud, sizeof(student)) &&
found == 0 ){
if(strcmpi(stud.retadmno(),n) == 0){
stud.show_student();
cout<<"\nEnter The New Details of
student"<<endl;
stud.modify_student_name();
int pos = -1 * sizeof(stud);
fio.seekp(pos, ios::cur);
fio.write((char*)&stud, sizeof(student));
cout<<"\n\n\t Record Updated";
found = 1;
}
}
fio.close();
if( found == 0 ) cout<<"\n\n Record Not Found ";
getch();
}

PAGE 19
//*****************************************
**********************
// Function to Delete record of file
//*****************************************
***********************

void delete_student(){
char n[6];
int flag = 0;
clrscr();
cout<<"\n\n\n\tDELETE STUDENT...";
cout<<"\n\nEnter The admission no. of the
Student You Want To Delete : ";
cin>>n;
fio.open("student.dat", ios::in|ios::out);
fstream fio2;
fio2.open("Temp.dat", ios::out);
fio.seekg(0, ios::beg);
while(fio.read((char*)&stud, sizeof(student))){
if(strcmpi(stud.retadmno(), n) != 0)
fio2.write((char*)&stud, sizeof(student));
else
flag = 1;
}

PAGE 20
fio2.close();
fio.close();
remove("student.dat");
rename("Temp.dat", "student.dat");
if( flag == 1 )
cout<<"\n\n\tRecord Deleted ..";
else
cout<<"\n\nRecord not found";
getch();
}

void delete_book(){
char n[6];
clrscr();
cout<<"\n\n\n\tDELETE BOOK ...";
cout<<"\n\nEnter Book number of Book to
Delete : ";
cin >> n;
fio.open("book.dat", ios::in|ios::out);
fstream fio2;
fio2.open("Temp.dat", ios::out);
fio.seekg(0, ios::beg);
while( fio.read((char*)&book1, sizeof(book)))

PAGE 21
if(strcmpi(book1.retbook_number(),n)!=0)
fio2.write((char*)&book1, sizeof(book));
fio2.close();
fio.close();
remove("book.dat");
rename("Temp.dat","book.dat");
cout<<"\n\n\tRecord Deleted ..";
getch();
}

//*****************************************
**********************
// Function to display all students list
//*****************************************
***********************

void display_alls(){
clrscr();
fio.open("student.dat",ios::in);
if(fio==NULL){
cout<<"ERROR!!! FILE COULD NOT BE
OPEN ";
getch();

PAGE 22
return; }

cout<<"\n\n\t\tSTUDENT LIST\n\n";

cout<<"===============================
============\n";
cout<<"\tAdmission
No."<<setw(10)<<"Name"<<setw(20)
<<"Book Issued\n";

cout<<"===============================
============\n";

while(fio.read((char*)&stud, sizeof(student)))
stud.report();

fio.close();
getch();
}

//*****************************************
**********************
// Function to display Books list

PAGE 23
//*****************************************
***********************

void display_all_books(){
clrscr();
fio.open("book.dat", ios::in);
if(fio==NULL){
cout<<"ERROR!!! FILE COULD NOT BE
OPEN ";
getch();
return;
}
cout<<"\n\n\t\tBook LIST\n\n";

cout<<"===============================
============\n";
cout<<"Book Number"<<setw(20)
<<"BookName"<<setw(25)<<"Author\n";

cout<<"===============================
==========\n";
while(fio.read((char*)&book1, sizeof(book)))
book1.report();
fio.close();
getch();

PAGE 24
}

//*****************************************
**********************
// function to issue book
//*****************************************
***********************

void book_issue(){
char sn[6], bn[6];
int found = 0, flag = 0;
clrscr();
cout<<"\n\nBOOK ISSUE ...";
cout<<"\n\n\tEnter Student's Admission number :
";
cin>>sn;
fio.open("student.dat", ios::in|ios::out);
fio1.open("book.dat", ios::in|ios::out);
while(fio.read((char*)&stud, sizeof(student)) &&
found == 0){
if(strcmpi(stud.retadmno(), sn) == 0){
found = 1;
if(stud.rettoken() == 0){

PAGE 25
cout<<"\n\n\tEnter Book number : ";
cin>>bn;
while(fio1.read((char*)&book1,
sizeof(book)) && flag==0){
if(strcmpi(book1.retbook_number(), bn)
== 0){
book1.show_book();
flag = 1;
stud.addtoken();

stud.getstbook_number(book1.retbook_number());
int pos = -1 * sizeof(stud);
fio.seekp(pos, ios::cur);
fio.write((char*)&stud,
sizeof(student));
cout<<"\n\n\t Book issued
successfully\n\nPlease Note: Write the current date
in backside of your book \n and submit within 15
days fine Rs. 1 for each day \n after 15 days period";
}
}
if( flag == 0 ) cout<<"Book number does
not exist";
}
else

PAGE 26
cout<<"You have not returned the last
book ";

}
}
if(found == 0)
cout<<"Student record not exist...";
getch();
fio.close();
fio1.close();
}

//*****************************************
**********************
// Function to deposit book
//*****************************************
***********************

void book_deposit()
{
char sn[6],bn[6];
int found = 0, flag = 0, day, fine;
clrscr();
cout<<"\n\nBOOK DEPOSIT ...";

PAGE 27
cout<<"\n\n\tEnter Student’s Admission number :
";
cin>>sn;
fio.open("student.dat", ios::in|ios::out);
fio1.open("book.dat", ios::in|ios::out);
while(fio.read((char*)&stud, sizeof(student)) &&
found == 0){
if(strcmpi(stud.retadmno(), sn)==0){
found = 1;
if(stud.rettoken() == 1){
while(fio1.read((char*)&book1,
sizeof(book))&& flag==0){

if(strcmpi(book1.retbook_number(),stud.retstbook_n
umber())==0)
{
book1.show_book();
flag = 1;
cout<<"\n\nBook deposited in no. of
days : ";
cin>>day;
if(day > 15){
fine = (day-15) * 1;
cout<<"\n\nFine to deposited is Rs.
"<<fine;

PAGE 28
}
stud.resettoken();
int pos = -1 * sizeof(stud);
fio.seekp(pos,ios::cur);
fio.write((char*)&stud,
sizeof(student));
cout<<"\n\n\t Book deposited
successfully";
}
}
if(flag==0)cout<<"Book no does not
exist";
}
else cout<<"No book is issued..please
check!!";
}
}
if(found==0) cout<<"Student record not exist...";
getch();
fio.close();
fio1.close();
}

//*****************************************
**********************

PAGE 29
// INTRODUCTION FUNCTION
//*****************************************
***********************

void intro(){
clrscr();
gotoxy(35,11);
cout<<"LIBRARY";
gotoxy(35,14);
cout<<"MANAGEMENT";
gotoxy(35,17);
cout<<"SYSTEM";
cout<<"\n\nMADE BY:- HEMANT
UPADHYAY";
getch();
}

//*****************************************
**********************
// ADMINISTRATOR MENU FUNCTION
//*****************************************
***********************

void admin_menu(){
clrscr();

PAGE 30
int ch2;
char num[6];
cout<<"\n\n\n\tADMINISTRATOR MENU";
cout<<"\n\n\t(1) CREATE STUDENT
RECORD";
cout<<"\n\n\t(2) DISPLAY ALL STUDENTS
RECORD";
cout<<"\n\n\t(3) DISPLAY SPECIFIC
STUDENT RECORD ";
cout<<"\n\n\t(4) MODIFY STUDENT
RECORD";
cout<<"\n\n\t(5) DELETE STUDENT
RECORD";
cout<<"\n\n\t(6) CREATE BOOK ";
cout<<"\n\n\t(7) DISPLAY ALL BOOKS ";
cout<<"\n\n\t(8) DISPLAY SPECIFIC BOOK ";
cout<<"\n\n\t(9) MODIFY BOOK ";
cout<<"\n\n\t(10) DELETE BOOK ";
cout<<"\n\n\t(11) BACK TO MAIN MENU";
cout<<"\n\n\tPlease Enter Your Choice (1-11) ";
cin>>ch2;
switch(ch2){
case 1:
clrscr();
write_student();

PAGE 31
break;
case 2:
display_alls();
break;
case 3:
clrscr();
cout<<"\n\n\tPlease Enter The Admission No.
";
cin>>num;
display_specific_student(num);
break;
case 4:
modify_student_name();
break;
case 5:
delete_student();
break;
case 6:
clrscr();
write_book();
break;
case 7:
display_all_books();
break;
case 8:

PAGE 32
clrscr();
cout<<"\n\n\tPlease Enter The book No. ";
cin>>num;
display_specific_book(num);
break;
case 9:
modify_book();
break;
case 10:
delete_book();
break;
case 11: return;
default:
cout<<"\a";
}
admin_menu(); //recursion
}

//*****************************************
**********************
// THE MAIN FUNCTION OF PROGRAM
//*****************************************
***********************

PAGE 33
void main(){
char ch;
intro();
do{
clrscr();
cout<<"\n\n\n\tMAIN MENU";
cout<<"\n\n\t(1) BOOK ISSUE";
cout<<"\n\n\t(2) BOOK DEPOSIT";
cout<<"\n\n\t(3) ADMINISTRATOR MENU";
cout<<"\n\n\t(4) EXIT";
cout<<"\n\n\tPlease Select Your Option (1-4) ";
ch = getche();
switch(ch){
case '1':
clrscr();
book_issue();
break;
case '2':
book_deposit();
break;
case '3':
admin_menu();
break;
case '4': exit(0);
default :

PAGE 34
cout<<"\a";
cout<<"Invaild entry";
}//end of switch
}while(ch!='4');
}

//*****************************************
**********************
//END OF PROGRAM
//********************************************
******************

I am so happy on completing my project work with in


time. On doing so I got familiar with several topics
that were unknown to me.
This project would be nearly incomplete if had not
used the information given in the following websites:
1. https://google.com/
2. https://en.wikipedia.org
3. Computer science with C++ by Sumita Arora

PAGE 35

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