Objective of Project: To Provide A Library Management System For College
Objective of Project: To Provide A Library Management System For College
Scope of Project:
Page | 1
Process model used
The waterfall model, sometimes called the classic life cycle, suggests a
systematic, sequential approach to software development that begins with
customer specification of requirements and progresses through planning,
modeling, construction and deployment, culminating in on-going support of
the complete software.
I have defined activities and represented them into separated process phases.
All the stages overlap and fed information to each other. It is not a simple
linear model but involves a sequence of iterations of development activities.
Page | 2
Software Requirements Specification
Functional requirements:
Data requirements:
4, 120 MB RAM.
Page | 3
Services provided to the user
The functions that the Library Management System provides are as follows:
Page | 4
b) Teacher: This will clear the record for a particular teacher
whose identification number is entered. This option is chosen
when a teacher leaves college.
c) Student: This will clear the record for the particular student
whose record needs to be deleted by entering her roll number in
the required field. This option is chosen when a student leaves
college.
3. UPDATE: This function updates data in the various records. This
operation is supported by all the three entries:
a) Book: This function generally would not be required for
updating a book’s status as that data wouldn’t change.
b) Teacher: This will update the data of particular teacher, whose
data has changed like address, phone number, etc. by entering
her identification number.
c) Student: This will update the data of student like address,
course, etc. by entering student’s roll number.
4. SEARCH: This function is used to search particular data from the
database. This function can search for data related to all the three
entities:
a) Book: To search for a particular book, to know whether it is
currently available in library or not. This can be done by
entering value in any one or more fields in the form to perform
the search such as title or author name.
b) Teacher: This will find out the particular teacher who currently
has the book for which search is being carried out.
c) Student: This will find out the particular student who possesses
the particular book.
5. ISSUE: This operation is used for issuing a book to a member of the
library. For this operation to be successful the member must meet some
criteria like she should not have issued books to her maximum limit
previously. All these checks are done by software. If the operation is
successful, then the system automatically stores the date of issue and the
due date by which the book must be returned.
a) Student: When a student loans a book, the entry of the book is
stored automatically in the student’s database with the due date
of that book.
b) Teacher: In case a member of teaching staff loans a book the
entry is stored in teacher’s database with the due date of the
book.
Page | 5
6. RETURN: Using this operation a member returns the items, which
she loaned, from the library back to it. If the book, which is loaned
is not returned within specified time the member ends up as a
defaulter and she is required to pay fine which is calculated
automatically by the software.
a) Teacher: It will delete the corresponding entry made in
teacher’s database.
b) Student: It will delete the corresponding entry made in
student’s database.
7. DISPLAY: This is used to display each and every record, i.e.
record of every book, teacher and student in the library.
a) Book: Record of every book, i.e. its accession number,
author name, publisher name, etc.
b) Teacher: Record of every teacher, i.e. her id, department,
no. of books issued, etc., who is member of the college
library.
c) Student: Record of every student, i.e. her roll number,
course, no of books issued, etc., who is member of the
college library.
8. EXIT: This takes user out of the application.
Page | 6
Page | 7
Data Flow Diagrams
Page | 8
Page | 9
Page | 10
Source Code
//**********************************************************
// PROJECT BOOK LIBRARY
//**********************************************************
//**********************************************************
// INCLUDED HEADER FILES
//**********************************************************
#include <iostream.h>
#include <fstream.h>
#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>
//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU
//**********************************************************
class MENU
{
public :
void main_menu(void) ;
void introduction(void) ;
private :
void edit_menu(void) ;
void edit_book(void) ;
void edit_member(void) ;
} ;
//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO BOOKS
//**********************************************************
class BOOK
{
public :
void list(void) ;
char *bookname(int) ;
protected :
void add_new_book(int, char tname[33], char
tauthor[26], float, int, int) ;
void update_copies(int, int, int) ;
void modify(int, char[], char[], float) ;
void deletion(void) ;
Page | 11
int book_found(int) ;
int bookname_found(char []) ;
int recordno(int) ;
int available(int) ;
char *authorname(int) ;
float bookprice(int) ;
int no_of_copies(int) ;
int bookcodeof(char[]) ;
void display(int) ;
int reccount(void) ;
void delete_rec(int) ;
private :
int bookcode, copies ;
char name[33], author[26] ;
float price ;
int avail ;
} ;
//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO MEMBERS
//**********************************************************
class MEMBER
{
public :
void list(void) ;
protected :
void add_mem(int, int, char [], char [], char[], int,
int, int) ;
void modify(int, char[], char[], char[]) ;
int member_found(int) ;
void update_book(int, int, int, int, int) ;
char *membername(int) ;
char *memberphone(int) ;
char *memberaddress(int) ;
int recordno(int) ;
int lastcode(void) ;
int issued(int) ;
int fine(int) ;
void display(int) ;
void delete_rec(int) ;
private :
int memcode, bookcode ;
char name[26], phone[10], address[33] ;
int dd, mm, yy ; // DATE OF RETURNING THE BOOK //
} ;
//**********************************************************
// THIS IS DERIVED FROM CLASS BOOK & MEMBER AND CONTAINS
// FUNCTIONS FOR WORKING (ISSUE,RETURN,ETC).
//**********************************************************
Page | 12
void issuebook(void) ;
void returnbook(void) ;
void add_book(void) ;
void add_member(void) ;
void modify_book(void) ;
void modify_member(void) ;
void delete_book(void) ;
void delete_member(void) ;
} ;
//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED DATE & FINE
//**********************************************************
class DATE
{
public :
void extend_date(int,int,int,int) ;
int diff(int, int, int, int, int, int) ;
int day, mon, year ;
} ;
//**********************************************************
// FUNCTION TO EXTEND GIVEN DATE BY 15 DAYS
//**********************************************************
void DATE :: extend_date(int d1, int m1, int y1, int days)
{
static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
for (int i=1; i<=days; i++)
{
d1++ ;
if ((d1 > month[m1-1]) || (y1%4 != 0 && m1 == 2 && d1 > 28))
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
day = d1 ;
mon = m1 ;
year = y1 ;
}
//**********************************************************
// THIS FUNCTION RETURN THE DIFFERENCE BETWEEN TWO GIVEN
// DATES
//**********************************************************
Page | 13
int DATE :: diff(int d1, int m1, int y1, int d2, int m2, int y2)
{
int days = 0 ;
if ((y2<y1) || (y2==y1 && m2<m1) || (y2==y1 && m2==m1 && d2<d1))
return days ;
static int month[] = {31,29,31,30,31,30,31,31,30,31,30,31} ;
while (d1 != d2 || m1 != m2 || y1 != y2)
{
days++ ;
d1++ ;
if ((d1 > month[m1-1]) || (y1%4 != 0 && m1 == 2 && d1 > 28))
{
d1 = 1 ;
m1++ ;
}
if (m1 > 12)
{
m1 = 1 ;
y1++ ;
}
}
return days ;
}
//**********************************************************
// FUNCTION TO DISPLAY MAIN MENU & CONTROL ALL THE FUNCTION
// IN THE MAIN MENU.
//**********************************************************
Page | 14
cout <<"0. QUIT" ;
gotoxy(30,20) ;
cout <<"Enter your choice : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
introduction() ;
else
if (ch == '2')
{
WORKING W ;
W.add_book() ;
}
else
if (ch == '3')
{
WORKING W ;
W.add_member() ;
}
else
if (ch == '4')
{
WORKING W ;
W.issuebook() ;
}
else
if (ch == '5')
{
WORKING W ;
W.returnbook() ;
}
else
if (ch == '6')
{
BOOK B ;
B.list() ;
}
else
if (ch == '7')
{
MEMBER M ;
M.list() ;
}
else
if (ch == '8')
edit_menu() ;
else
if (ch == '0')
break ;
}
}
//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU
Page | 15
//**********************************************************
//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU FOR BOOK & CONTROL
// ALL THE FUNCTION IN THE EDIT MENU.
//**********************************************************
Page | 16
gotoxy(31,17) ;
cout <<"Enter your choice : " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
WORKING W ;
W.modify_book() ;
}
else
if (ch == '2')
{
WORKING W ;
W.delete_book() ;
}
else
if (ch == '0')
break ;
}
}
//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU FOR MEMBERS & CONTROL
// ALL THE FUNCTION IN THE EDIT MENU.
//**********************************************************
Page | 17
if (ch == '2')
{
WORKING W ;
W.delete_member() ;
}
else
if (ch == '0')
break ;
}
}
//**********************************************************
// FUNCTION TO DISPLAY THE INTRODUCTION FOR THE PROJECT.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURN 0 IF GIVEN BOOK CODE NOT FOUND
//**********************************************************
Page | 18
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
found = 1 ;
break ;
}
}
file.close() ;
return found ;
}
//**********************************************************
// THIS FUNCTION RETURN 0 IF GIVEN BOOK NAME NOT FOUND
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURN RECORD NO. FOR THE BOOK CODE
//**********************************************************
Page | 19
//**********************************************************
// THIS FUNCTION RETURNS THE AVAILABLE COPIES FOR THE GIVEN
// BOOK CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURNS THE NO. OF COPIES FOR THE GIVEN
// BOOK CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURNS THE BOOK NAME OF THE GIVEN BOOK
// CODE.
//**********************************************************
Page | 20
file.seekg(0,ios::beg) ;
char tname[33] ;
while (file.read((char *) this, sizeof(BOOK)))
{
if (bookcode == tcode)
{
strcpy(tname,name) ;
break ;
}
}
file.close() ;
return tname ;
}
//**********************************************************
// THIS FUNCTION RETURNS THE AUTHOR NAME OF THE GIVEN BOOK
// CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURNS THE BOOK PRICE OF THE GIVEN BOOK
// CODE.
//**********************************************************
Page | 21
}
file.close() ;
return tprice ;
}
//**********************************************************
// THIS FUNCTION RETURNS THE BOOK CODE OF THE GIVEN BOOK
// NAME.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURNS THE NO. OF THE RECORDS IN THE BOOK
// FILE.
//**********************************************************
//**********************************************************
// THIS FUNCTION DELETES THE RECORD OF THE GIVEN BOOK CODE.
//**********************************************************
Page | 22
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(BOOK)) ;
if ( file.eof() )
break ;
if ( bookcode != tcode )
temp.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
file.open("BOOK.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(BOOK)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
}
//**********************************************************
// THIS FUNCTION ADD THE RECORD IN THE BOOK FILE
//**********************************************************
//**********************************************************
// THIS FUNCTION UPDATE THE RECORD IN THE BOOK FILE FOR THE
// GIVEN BOOK CODE
//**********************************************************
Page | 23
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(BOOK)) ;
if ( file.eof() )
break ;
if ( bookcode == tcode )
{
copies = tcopies ;
avail = tavail ;
temp.write((char *) this, sizeof(BOOK)) ;
}
else
temp.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
file.open("BOOK.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(BOOK)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
}
//**********************************************************
// THIS FUNCTION MODIFY THE RECORD IN THE BOOK FILE FOR THE
// GIVEN BOOK CODE
//**********************************************************
Page | 24
}
else
temp.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
file.open("BOOK.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(BOOK)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(BOOK)) ;
}
file.close() ;
temp.close() ;
}
//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD FROM THE BOOK FILE
// FOR THE GIVEN BOOK CODE
//**********************************************************
//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF BOOKS.
//**********************************************************
Page | 25
void BOOK :: list(void)
{
clrscr() ;
int row = 6 , found=0, flag=0 ;
char ch ;
gotoxy(33,2) ;
cout <<"LIST OF BOOKS" ;
gotoxy(32,3) ;
cout <<"~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
cout <<"CODE BOOK NAME AUTHOR
PRICE COPIES" ;
gotoxy(1,5) ;
cout
<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~" ;
fstream file ;
file.open("BOOK.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(BOOK)))
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(2,row) ;
cout <<bookcode ;
gotoxy(7,row) ;
cout <<name ;
gotoxy(40,row) ;
cout <<author ;
gotoxy(66,row) ;
cout <<price ;
gotoxy(73,row) ;
cout <<copies ;
textbackground(WHITE) ; textcolor(BLACK) ;
gotoxy(40,row+1) ;
cprintf("STATUS: ") ;
textcolor(BLACK+BLINK) ;
cprintf("%d copies available",avail) ;
textbackground(BLACK) ; textcolor(LIGHTGRAY) ;
if ( row == 22 )
{
flag = 1 ;
row = 6 ;
gotoxy(1,25) ;
cout <<"Press any key to continue or Press <ESC> to
exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
gotoxy(33,2) ;
cout <<"LIST OF BOOKS" ;
gotoxy(32,3) ;
cout <<"~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
Page | 26
cout <<"CODE BOOK NAME AUTHOR
PRICE COPIES" ;
gotoxy(1,5) ;
cout
<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~" ;
}
else
row = row + 2 ;
}
if (!found)
{
gotoxy(5,10) ;
cout <<"\7Records not found" ;
}
if (!flag)
{
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
}
file.close () ;
}
//**********************************************************
// THIS FUNCTION RETURN 0 IF THE GIVEN MEMBER CODE NOT FOUND
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURN 0 IF THE MEMBER HAVE NOT ISSUED ANY
// BOOK.
//**********************************************************
Page | 27
file.seekg(0,ios::beg) ;
int missue=0 ;
while (file.read((char *) this, sizeof(MEMBER)))
{
if (memcode == mcode)
{
missue = bookcode ;
break ;
}
}
file.close() ;
return missue ;
}
//**********************************************************
// THIS FUNCTION CALCULATE AND RETURN FINE FOR THE GIVEN
// MEMBER CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURN THE LAST CODE OF THE MEMBER FILE.
//**********************************************************
Page | 28
while (file.read((char *) this, sizeof(MEMBER)))
mcode = memcode ;
file.close() ;
return mcode ;
}
//**********************************************************
// THIS FUNCTION RETURNS MEMBER NAME OF THE GIVEN MEMBER
// CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURNS MEMBER PHONE OF THE GIVEN MEMBER
// CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURNS MEMBER ADDRESS OF THE GIVEN MEMBER
Page | 29
// CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION RETURNS RECORD NO. OF THE GIVEN MEMBER
// CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION DELETE RECORD FOR THE GIVEN MEMBER CODE.
//**********************************************************
Page | 30
file.read((char *) this, sizeof(MEMBER)) ;
if ( file.eof() )
break ;
if ( memcode != mcode )
temp.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
file.open("MEMBER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
temp.read((char *) this, sizeof(MEMBER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
}
//**********************************************************
// THIS FUNCTION UPDATE RECORD FOR THE GIVEN MEMBER CODE.
//**********************************************************
void MEMBER :: update_book(int mcode, int tcode, int d1, int m1, int y1)
{
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
fstream temp ;
temp.open("temp.dat", ios::out) ;
file.seekg(0,ios::beg) ;
while ( !file.eof() )
{
file.read((char *) this, sizeof(MEMBER)) ;
if ( file.eof() )
break ;
if ( memcode == mcode )
{
bookcode = tcode ;
dd = d1 ;
mm = m1 ;
yy = y1 ;
temp.write((char *) this, sizeof(MEMBER)) ;
}
else
temp.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
file.open("MEMBER.DAT", ios::out) ;
temp.open("temp.dat", ios::in) ;
temp.seekg(0,ios::beg) ;
while ( !temp.eof() )
{
Page | 31
temp.read((char *) this, sizeof(MEMBER)) ;
if ( temp.eof() )
break ;
file.write((char *) this, sizeof(MEMBER)) ;
}
file.close() ;
temp.close() ;
}
//**********************************************************
// THIS FUNCTION MODIFY RECORD FOR THE GIVEN MEMBER CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION ADD RECORD IN THE FILE FOR THE GIVEN
// MEMBER CODE.
Page | 32
//**********************************************************
//**********************************************************
// THIS FUNCTION DISPLAY THE RECORD FOR THE GIVEN MEMBER
// CODE.
//**********************************************************
//**********************************************************
// THIS FUNCTION DISPLAY THE LIST OF THE MEMBERS
//**********************************************************
Page | 33
clrscr() ;
BOOK B ;
int row = 6 , found=0, flag=0 ;
char ch ;
gotoxy(32,2) ;
cout <<"LIST OF MEMBERS" ;
gotoxy(31,3) ;
cout <<"~~~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
cout <<"CODE BOOK CODE NAME PHONE" ;
gotoxy(1,5) ;
cout
<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~" ;
fstream file ;
file.open("MEMBER.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(MEMBER)))
{
flag = 0 ;
delay(20) ;
found = 1 ;
gotoxy(2,row) ;
cout <<memcode ;
gotoxy(10,row) ;
cout <<bookcode ;
gotoxy(19,row) ;
cout <<name ;
gotoxy(48,row) ;
cout <<phone ;
textbackground(WHITE) ; textcolor(BLACK) ;
gotoxy(7,row+1) ;
if (bookcode == 0)
cprintf("BOOK NAME: (Not Issued)") ;
else
{
cprintf("BOOK NAME: %s",B.bookname(bookcode)) ;
gotoxy(42,row+1) ;
cprintf("Date of return: ") ;
textcolor(BLACK+BLINK) ;
cprintf("%d/%d/%d",dd,mm,yy) ;
}
textbackground(BLACK) ; textcolor(LIGHTGRAY) ;
if ( row == 22 )
{
flag = 1 ;
row = 6 ;
gotoxy(1,25) ;
cout <<"Press any key to continue or Press <ESC> to
exit" ;
ch = getch() ;
if (ch == 27)
break ;
clrscr() ;
gotoxy(32,2) ;
cout <<"LIST OF MEMBERS" ;
gotoxy(31,3) ;
Page | 34
cout <<"~~~~~~~~~~~~~~~~~" ;
gotoxy(1,4) ;
cout <<"CODE BOOK CODE NAME
PHONE" ;
gotoxy(1,5) ;
cout
<<"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~" ;
}
else
row = row + 2 ;
}
if (!found)
{
gotoxy(5,10) ;
cout <<"\nRecords not found" ;
}
if (!flag)
{
gotoxy(1,25) ;
cout <<"Press any key to continue..." ;
getche() ;
}
file.close () ;
}
//**********************************************************
// THIS FUNCTION GIVES DATA TO ADD RECORD IN THE BOOK FILE.
//**********************************************************
Page | 35
gotoxy(5,5) ;
cout <<"Code no. " ;
gets(t) ;
tc = atoi(t) ;
tcode = tc ;
if (tcode == 0)
return ;
if (book_found(tcode))
{
found = 1 ;
gotoxy(19,8) ;
cout <<bookname(tcode) ;
gotoxy(19,9) ;
cout <<authorname(tcode) ;
gotoxy(22,10) ;
cout <<bookprice(tcode) ;
}
gotoxy(5,8) ;
cout <<"Book Name : " ;
gotoxy(5,9) ;
cout <<"Author Name : " ;
gotoxy(5,10) ;
cout <<"Price : Rs." ;
gotoxy(5,12) ;
cout <<"Copies : " ;
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the book" ;
gotoxy(19,8) ; clreol() ;
gets(tname) ;
strupr(tname) ;
if (tname[0] == '0')
return ;
if (strlen(tname) < 1 || strlen(tname) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\nEnter correctly (Range: 1..32)" ;
getch() ;
}
}
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the author's name of the book" ;
gotoxy(19,9) ; clreol() ;
gets(tauthor) ;
strupr(tauthor) ;
if (tauthor[0] == '0')
return ;
if (strlen(tauthor) < 1 || strlen(tauthor) > 25)
{
Page | 36
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
}
valid = 0 ;
while (!valid && !found)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the price of the book" ;
gotoxy(22,10) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tprice = t2 ;
if (t1[0] == '0')
return ;
if (tprice < 1 || tprice > 9999)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
}
valid = 0 ;
while (!valid)
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter no. of copies of book to be added" ;
gotoxy(19,12) ; clreol() ;
gets(t) ;
tc = atoi(t) ;
tcopies = tc ;
if (t[0] == '0')
return ;
if (tcopies < 1 || tcopies > 50)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
}
tavail = available(tcode) + tcopies ;
tcopies = no_of_copies(tcode) + tcopies ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,15) ; clreol() ;
cout <<"Do you want to save (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
Page | 37
if (ch == 'Y')
{
if (found)
update_copies(tcode,tcopies,tavail) ;
else
add_new_book(tcode,tname,tauthor,tprice,tcopies,tavail) ;
}
do
{
gotoxy(5,17) ; clreol() ;
cout <<"Do you want to add more (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
} while (ch != 'Y' && ch != 'N') ;
} while (ch == 'Y') ;
}
//**********************************************************
// THIS FUNCTION GIVES DATA TO ADD RECORD IN THE MEMBER FILE
//**********************************************************
Page | 38
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the New Member" ;
gotoxy(15,10) ; clreol() ;
gets(mname) ;
strupr(mname) ;
if (mname[0] == '0')
return ;
if (strlen(mname) < 1 || strlen(mname) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter Phone no. of the Member or Press <ENTER>
for none" ;
gotoxy(15,12) ; clreol() ;
gets(mphone) ;
if (mphone[0] == '0')
return ;
if ((strlen(mphone) < 7 && strlen(mphone) > 0) ||
(strlen(mphone) > 9))
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(mphone) == 0)
strcpy(mphone,"-") ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the address of the New Member" ;
gotoxy(15,14) ; clreol() ;
gets(maddress) ;
strupr(maddress) ;
if (maddress[0] == '0')
return ;
if (strlen(maddress) < 1 || strlen(maddress) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..32)" ;
getch() ;
}
} while (!valid) ;
Page | 39
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,17) ; clreol() ;
cout <<"Do you want to save (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'Y')
{
bcode = 0 ;
d1 = 0 ;
m1 = 0 ;
y1 = 0 ;
add_mem(mcode,bcode,mname,maddress,mphone,d1,m1,y1) ;
mcode++ ;
}
do
{
gotoxy(5,19) ; clreol() ;
cout <<"Do you want to add more (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
} while (ch == 'Y') ;
}
//**********************************************************
// THIS FUNCTION ISSUES THE BOOK
//**********************************************************
Page | 40
cout <<"Date : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,5) ;
cout <<"Enter Code or Name of the Book to be issued" ;
gotoxy(5,6) ;
cout <<" or " ;
gotoxy(5,7) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;
if ((tcode == 0 && !bookname_found(t1code)) || (tcode != 0
&& !book_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7Record not found" ;
gotoxy(5,11) ;
cout <<"Press <ESC> to exit or any other key to
continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = bookcodeof(t1code) ;
if (!available(tcode))
{
gotoxy(5,10) ;
cout <<"\7Sorry! Book (" <<bookname(tcode) <<") is not
available" ;
gotoxy(5,11) ;
cout <<"Kindly issue any other Book" ;
gotoxy(5,12) ;
cout <<"See List of Books" ;
getch() ;
return ;
}
do
{
valid = 1 ;
while (1)
{
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,2) ;
cout <<"Date : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
Page | 41
gotoxy(5,5) ;
cout <<"Book Name: " <<bookname(tcode) ;
gotoxy(5,7) ;
cout <<"Enter Code no. of the Member" ;
gotoxy(5,8) ;
cout <<" or " ;
gotoxy(5,9) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
M.list() ;
else
break ;
}
t2code = atoi(t1code) ;
mcode = t2code ;
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7Enter Correctly" ;
getch() ;
}
if (!member_found(mcode) && valid)
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Record not found" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to
continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
int tcopies, tavail ;
tcopies = no_of_copies(tcode) ; // member function of BOOK
tavail = available(tcode) - 1 ; // member function of BOOK
update_copies(tcode,tcopies,tavail) ; // member function of BOOK
D.extend_date(d1,m1,y1,15) ;
d1 = D.day ;
m1 = D.mon ;
y1 = D.year ;
update_book(mcode,tcode,d1,m1,y1) ; // member function of MEMBER
gotoxy(5,13) ;
cout <<"\7Book is issued to " <<membername(mcode) ;
gotoxy(5,15) ;
cout <<"Date of Return : " <<d1 <<"/" <<m1 <<"/" <<y1 ;
getch() ;
}
//**********************************************************
// THIS FUNCTION RETURNS THE BOOK FOR THE MEMBER
Page | 42
//**********************************************************
Page | 43
return ;
}
if (!issued(mcode) && valid)
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Member have no book to return" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to
continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
int bcode, tcopies, tavail ;
bcode = issued(mcode) ;
gotoxy(5,13) ;
cout <<"Book Code : " <<bcode ;
gotoxy(5,14) ;
cout <<"Book Name : " <<bookname(bcode) ;
tcopies = no_of_copies(bcode) ;
tavail = available(bcode) + 1 ;
int f ;
f = fine(mcode) ;
if (f != 0)
{
gotoxy(5,16) ;
cout <<"You have to pay a fine of Rs." <<f ;
gotoxy(5,17) ;
cout <<"Please do not delay the Return of Book again" ;
}
update_copies(bcode,tcopies,tavail) ;
update_book(mcode,0,0,0,0) ;
gotoxy(5,19) ;
cout <<"\7Book has been returned" ;
getch() ;
}
//**********************************************************
// THIS FUNCTION GIVES DATA TO MODIFY THE BOOK RECORD
//**********************************************************
Page | 44
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
gotoxy(5,5) ;
cout <<"Enter Code or Name of the Book to be modified"
;
gotoxy(5,6) ;
cout <<" or " ;
gotoxy(5,7) ;
cout <<"Press <ENTER> for help " ;
gets(t1code) ;
if (t1code[0] == '0')
return ;
if (strlen(t1code) == 0)
B.list() ;
else
break ;
}
t2code = atoi(t1code) ;
tcode = t2code ;
if ((tcode == 0 && !bookname_found(t1code)) || (tcode != 0
&& !book_found(tcode)))
{
valid = 0 ;
gotoxy(5,10) ;
cout <<"\7Record not found" ;
gotoxy(5,11) ;
cout <<"Press <ESC> to exit or any other key to
continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = bookcodeof(t1code) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
BOOK::display(tcode) ;
do
{
gotoxy(5,13) ; clreol() ;
cout <<"Do you want to modify this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
gotoxy(5,16) ;
cout <<"Book Name : " ;
gotoxy(5,17) ;
cout <<"Author Name : " ;
gotoxy(5,18) ;
cout <<"Price : Rs." ;
do
Page | 45
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the book or <ENTER> for no change"
;
gotoxy(19,16) ; clreol() ;
gets(tname) ;
strupr(tname) ;
if (tname[0] == '0')
return ;
if (strlen(tname) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..32)" ;
getch() ;
}
} while (!valid) ;
if (strlen(tname) == 0)
strcpy(tname,bookname(tcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the author's name or <ENTER> for no change" ;
gotoxy(19,17) ; clreol() ;
gets(tauthor) ;
strupr(tauthor) ;
if (tauthor[0] == '0')
return ;
if (strlen(tauthor) > 25)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\nEnter correctly (Range: 1..25)" ;
getch() ;
}
} while (!valid) ;
if (strlen(tauthor) == 0)
strcpy(tauthor,authorname(tcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter price or <ENTER> for no change" ;
gotoxy(22,18) ; clreol() ;
gets(t1) ;
t2 = atof(t1) ;
tprice = t2 ;
if (t1[0] == '0')
return ;
if (strlen(t1) == 0)
break ;
if (tprice < 1 || tprice > 9999)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
Page | 46
cout <<"\nEnter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(t1) == 0)
tprice = bookprice(tcode) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,20) ; clreol() ;
cout <<"Do you want to save changes (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
BOOK::modify(tcode,tname,tauthor,tprice) ;
gotoxy(5,23) ;
cout <<"\nRecord Modified" ;
getch() ;
}
//**********************************************************
// THIS FUNCTION GIVES DATA TO MODIFY THE MEMBER RECORD
//**********************************************************
Page | 47
break ;
}
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7Enter Correctly" ;
getch() ;
}
if (valid && !member_found(mcode))
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Record not found" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to
continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
MEMBER::display(mcode) ;
do
{
gotoxy(5,10) ; clreol() ;
cout <<"Do you want to modify this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
gotoxy(5,13) ;
cout <<"Name : " ;
gotoxy(5,14) ;
cout <<"Phone : " ;
gotoxy(5,15) ;
cout <<"Address : " ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the name of the member or <ENTER> for no
change" ;
gotoxy(19,13) ; clreol() ;
gets(mname) ;
strupr(mname) ;
if (mname[0] == '0')
return ;
if (strlen(mname) > 25)
{
valid = 0 ;
Page | 48
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..25)" ;
getch() ;
}
}
while (!valid) ;
if (strlen(mname) == 0)
strcpy(mname,membername(mcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the Phone no. of Member or <ENTER> for no
change" ;
gotoxy(19,14) ; clreol() ;
gets(mphone) ;
if (mphone[0] == '0')
return ;
if ((strlen(mphone) < 7 && strlen(mphone) > 0) ||
(strlen(mphone) > 9))
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly" ;
getch() ;
}
} while (!valid) ;
if (strlen(mphone) == 0)
strcpy(mphone,memberphone(mcode)) ;
do
{
valid = 1 ;
gotoxy(5,25) ; clreol() ;
cout <<"Enter the address of the member or <ENTER> for no
change" ;
gotoxy(19,15) ; clreol() ;
gets(maddress) ;
strupr(maddress);
if(maddress[0]=='0')
return ;
if (strlen(maddress) > 32)
{
valid = 0 ;
gotoxy(5,25) ; clreol() ;
cout <<"\7Enter correctly (Range: 1..32)" ;
getch() ;
}
} while (!valid) ;
if (strlen(maddress) == 0)
strcpy(maddress,memberaddress(mcode)) ;
gotoxy(5,25) ; clreol() ;
do
{
gotoxy(5,18) ; clreol() ;
cout <<"Do you want to save changes (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
Page | 49
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
MEMBER::modify(mcode,mname,mphone,maddress) ;
gotoxy(5,23) ;
cout <<"\7Record Modified" ;
getch() ;
}
//**********************************************************
// THIS FUNCTION GIVES BOOK CODE TO DELETE THE BOOK RECORD
//**********************************************************
Page | 50
if (ch == 27)
return ;
}
} while (!valid) ;
if (tcode == 0)
tcode = bookcodeof(t1code) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
BOOK::display(tcode) ;
do
{
gotoxy(5,13) ; clreol() ;
cout <<"Do you want to delete this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
int tavail, tcopies ;
tavail = available(tcode) ;
tcopies = no_of_copies(tcode) ;
if (tavail != tcopies)
{
gotoxy(5,15) ;
cout <<"\7Record cannot be deleted. This book is issued." ;
getch() ;
return ;
}
BOOK::delete_rec(tcode) ;
gotoxy(5,23) ;
cout <<"\7Record Deleted" ;
getch() ;
}
//**********************************************************
// THIS FUNCTION GIVES MEMBER CODE TO DELETE THE MEMBER
// RECORD
//**********************************************************
Page | 51
gotoxy(5,7) ;
cout <<"Enter Code no. of the Member to be Deleted" ;
gotoxy(5,8) ;
cout <<" or " ;
gotoxy(5,9) ;
cout <<"Press <ENTER> for help " ;
gets(m1code) ;
m2code = atoi(m1code) ;
mcode = m2code ;
if (m1code[0] == '0')
return ;
if (strlen(m1code) == 0)
M.list() ;
else
break ;
}
if (mcode == 0)
{
valid = 0 ;
gotoxy(5,25) ;
cout <<"\7Enter Correctly" ;
getch() ;
}
if (valid && !member_found(mcode))
{
valid = 0 ;
gotoxy(5,13) ;
cout <<"\7Record not found" ;
gotoxy(5,14) ;
cout <<"Press <ESC> to exit or any other key to
continue..." ;
ch = getch() ;
if (ch == 27)
return ;
}
} while (!valid) ;
clrscr() ;
gotoxy(72,1) ;
cout <<"<0>=Exit" ;
MEMBER::display(mcode) ;
do
{
gotoxy(5,10) ; clreol() ;
cout <<"Do you want to Delete this record (y/n) : " ;
ch = getche() ;
ch = toupper(ch) ;
if (ch == '0')
return ;
} while (ch != 'Y' && ch != 'N') ;
if (ch == 'N')
return ;
if (issued(mcode))
{
gotoxy(5,15) ;
cout <<"\7Record cannot be delete. Member has a book" ;
getch() ;
return ;
Page | 52
}
MEMBER::delete_rec(mcode) ;
gotoxy(5,23) ;
cout <<"\7Record Modified" ;
getch() ;
}
//**********************************************************
// MAIN FUNCTION CALLING INTRODUCTION AND MAIN MENU
//**********************************************************
void main(void)
{
MENU menu ;
menu.introduction() ;
menu.main_menu() ;
}
OUTPUT
Page | 53
Page | 54
Main menu of the program.
Page | 55
From main menu choice 1 is selected.
Page | 56
choice 5 is selected.
Page | 57
In main menu choice 3 is selected.
Page | 58
Choice 5 is selected.
Page | 59
Choice 6 is selected to issue a book to the student.
Page | 60
Choice 5 is selected to show the changes in the student’s info after issuing a
book.
Testing
Page | 61
It is integral part of any system’s development life cycle without which the
system developed is sure to fail and result in loss of economic and
manpower investments besides user’s dissatisfaction and downfall of
reputation.
Another reason for system testing is its utility as a user oriented vehicle
before implementation. The application system is worthless if does not meet
user needs, thus the system should be tested to see whether it meets the user
requirements.
Bibliography
Page | 62
1. Let Us C by Yashavant Kanetkar
2. Computer Science, C++ by Sumita Arora
3. The Complete Reference, C++ by Herbert Schildt
4. Software Engineering by Roger S. Pressman
Page | 63