Final Project Best
Final Project Best
BANGALORE EAST
COMPUTER SCIENCE
INVESTIGATORY PROJECT
ACADEMIC YEAR 2019-20
DONE BY:
1
PRESIDENCY SCHOOL
BANGALORE EAST
CERTIFICATE
Name: ______________ Class: ____
Roll No: ______________
This is certified to be the bona fide work of the student in the Computer
Science laboratory during the academic year 2019-2020.
_________________________ ____________
TEACHER INCHARGE HOD
_______________________ ____________
EXAMINER’S SIGNATURE PRINCIPAL
DATE: _____________
INSTITUTION RUBBER STAMP
2
ACKNOWLEDGEMENT
JAYANTH B
ASAD AZIZ
3
INDEX
1. System Specification at a glance
2. Modules
3. Files
4. Requirement Analysis
5. System Specification Design
6. Data Design
7. Overview Of C++
8. Header Files
9. File Design Structure
10. Procedure/Function Description
11. Source Code
12. Output Screen
13. Future Enhancement
14. Bibliography
4
SYSTEM SPECIFICATION AT A GLANCE
1. Book Issue
2. Book Deposit
3. Administrator :
e) Add Books
f) Display Books
g) Modify Books
h) Delete Books
5
MODULES
1. Input Module:
All inputs to program are made in this module. This module consists of the
following functionality:
Inputs details of a new books like book no, book name, author name and
inputs details of a new students like admission no, student name.
6
2. Display Module:
All outputs in the program are made in this module. This module consists
of the following functionality:
Display of list of books and students like book no, book name, author
name and admission no, student name.
3. Update Module:
All modification regarding the books and students are made in this
module.
7
FILES
1. Student.dat file:
a) Admission number: It stores the admission number if the student.
b) Student name: It stores the name of student.
2. Book.dat file:
a) Book number: It stores the book number of a particular book.
b) Book Name: It stores name of the book.
c) Author name: It stores the name of the author of the book.
8
REQUIREMENT ANALYSIS
1 create_product() Product No
Name
Price -
Discount
2 display_product() Product No
Name
- Price
Discount
9
Hardware Requirements
RAM -2 GB
Software Components
10
START
1 .Issue Books
2 .Deposit Books
3. Admin Menu
4. Exit
If choice==1 book_issue()
If choice==2 book_deposit()
If choice==3 admin_menu()
If choice==4 exit
11
False
Print ”Book Issued”
exit
main()
False
Print ”Book Deposited”
exit
main()
If choice==5 If choice==7
If choice==6
write_book() modify_book()
display_allb()
delete_student()
If choice==8 If choice==9
13
admin_menu() Store in student.dat file
Display files of
display_alls() student.dat file
admin_menu()
14
admin_menu() Store in book.dat file
Display files of
display_allb() book.dat file
admin_menu()
15
Data members:
(private, if not mentioned otherwise)
• char bno[6]
• char bname[50]
• char aname[20]
Member functions:
16
(all public)
• void create_book()
• void show_book()
• void modify_book()
• void repor
• char* retname()
• int retdis()
Class student
17
Data members:
(private, if not mentioned otherwise)
• char admno[6]
• char name[20]
• char stbno[6]
• int token
Member functions:
18
(all public)
• void create_student()
• void show_student()
• void modify_student()
• int rettoken()
Overview of C++
19
Classes and objects:-
A class is similar to a C structure, except that the definition of the data structure
and all of the functions that operate on the data structure are grouped together in
one place. An object is an instance of a class (an instance of the data structure);
objects share the same functions with other objects of the same class, but each
object (each instance) has its own copy of the data structure. A class thus
defines two aspects of the objects: the data they contain, and the behavior they
have.
Member functions:-
These are functions which are considered part of the object and are declared in
the class definition. They are often referred to as methods of the class. In
addition to member functions, a class's behavior is also defined by:
What to do when you create a new object (the constructor for that object) -- in
other words, initialize the object's data.
What to do when you delete an object (the destructor for that object).
BASIC CONCEPTS OF
20
C++ PROGRAM
➢Objects
➢Classes
➢Inheritance
➢Data Abstraction
➢Data Encapsulation
➢Polymorphism
➢Overloading
➢Reusability
Classes:-
Classes are data types based on which objects are created. Objects with similar
properties and methods are grouped together to form a Class. Thus a Class
represent a set of individual objects. Characteristics of an object are represented
in a class as Properties. The actions that can be performed by objects becomes
functions of the class and is referred to as Methods.
No memory is allocated when a class is created. Memory is allocated only when
an object is created, i.e., when an instance of a class is created.
Inheritance:-
21
Inheritance is the process of forming a new class from an existing class or base
class. The base class is also known as parent class or super class, The new class
that is formed is called derived class. Derived class is also known as a child
class or sub class. Inheritance helps in reducing the overall code size of the
program, which is an important concept in object-oriented programming.
Data Abstraction:-
Data Abstraction increases the power of programming language by creating
user defined data types. Data Abstraction also represents the needed
information in the program without presenting the details.
Data Encapsulation:-
Data Encapsulation combines data and functions into a single unit called Class.
When using Data Encapsulation, data is not accessed directly; it is only
accessible through the functions present inside the class. Data Encapsulation
enables the important concept of data hiding possible.
Polymorphism:-
Polymorphism allows routines to use variables of different types at different
times. An operator or function can be given different meanings or functions.
Polymorphism refers to a single function or multi-functioning operator
performing in different ways.
Overloading:-
22
Overloading is one type of Polymorphism. It allows an object to have different
meanings, depending on its context. When an exiting operator or function
begins to operate on new data type, or class, it is understood to be overloaded.
Reusability:-
This term refers to the ability for multiple programmers to use the same written
and debugged existing class of data. This is a time saving device and adds code
efficiency to the language. Additionally, the programmer can incorporate new
features to the existing class, further developing the application and allowing
users to achieve increased performance. This time saving feature optimises
code, helps in gaining secured applications and facilitates easier maintenance on
the application
HEADER FILES
23
HEADER ASSOCIATED
FILE FUNCTION
conio.h clrscr()
gotoxy()
getch()
goto()
stdio.h gets()
puts()
process.h exit()
fstream.h
tellg()
seekg()
seekp()
cout
cin
CLASS STUDENT
25
SL. FUNCTION DESCRIPTION
NO
1. create_student() Creates Student Record.
OTHER FUNCTIONS
26
SL FUNCTION DESCRIPTION
NO
1. write_book() Adding book records.
2. write_student() Adding student records.
3. display_spb() Display specific Books.
4. display_sps() Display specific students.
5. delete_student() Delete Student records.
6. delete_book() Delete Book Records.
7. display_alls() Display all Students.
8. display_allb() Display all Books Records.
9. book_issue() Issue Books.
10. book_deposit() Deposit Books.
11. intro() Introduction page display.
12. admin_menu() Admin menu display.
SOURCE CODE
27
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<ctype.h>
#include<string.h>
#include<iomanip.h>
class book
{
char bno[6];
char bname[50];
char aname[20];
public:
void create_book()
{
cout<<"\nNEW BOOK ENTRY...\n";
cout<<"\nEnter The book no.:";
cin>>bno;
cout<<"\n\nEnter The Name of The Book: ";
gets(bname);
xx:cout<<"\n\nEnter The Author's Name: ";
gets(aname);
int cnn=strlen(aname);
for(int z=0;z<cnn;z++)
28
{
if((!(isalpha(aname[z])||aname[z]==' ')))
{
cout<<"\nEnter valid name";
getch();
goto xx;
}
}
cout<<"\n\n\nBook Created..";
}
void show_book()
{
cout<<"\nBook no. : "<<bno;
cout<<"\nBook Name : ";
puts(bname);
cout<<"Author Name : ";
puts(aname);
}
void modify_book()
{
cout<<"\nBook no.: "<<bno;
29
cout<<"\nModify Book Name: ";
gets(bname);
x1:cout<<"\nModify Author's Name of Book: ";
gets(aname);
int cnn=strlen(aname);
for(int z=0;z<cnn;z++)
{
if((!(isalpha(aname[z])||aname[z]==' ')))
{
cout<<"\nEnter valid name";
getch();
goto x1;
}
}
}
char* retbno()
{
return bno;
}
void report()
{cout<<bno<<setw(40)<<bname<<setw(30)<<aname<<endl
};
30
class student
{
char admno[6];
char name[20];
char stbno[6];
int token;
public:
void create_student()
{
clrscr();
cout<<"\nNEW STUDENT ENTRY...\n";
cout<<"\nEnter The admission no.: ";
cin>>admno;
x2:cout<<"\n\nEnter The Name of The Student: ";
gets(name);
int cnn=strlen(name);
for(int z=0;z<cnn;z++)
{
if((!(isalpha(name[z])||name[z]==' ')))
{
cout<<"\nEnter valid name";
getch();
goto x2;
}
31
}
token=0;
stbno[0]='/0';
cout<<"\n\nStudent Record Created..";
}
void show_student()
{
cout<<"\nAdmission no.: "<<admno;
cout<<"\nStudent Name: ";
puts(name);
cout<<"\nNo of Book issued: "<<token;
if(token==1)
cout<<"\nBook No: "<<stbno;
}
void modify_student()
{
cout<<"\nAdmission no.: "<<admno;
cout<<"\nModify Student Name: ";
x3:gets(name);
int cnn=strlen(name);
for(int z=0;z<cnn;z++)
{
32
if((!(isalpha(name[z])||name[z]==' ')))
{
cout<<"\nEnter valid name";
getch();
goto x3;
}
}
}
char* retadmno()
{
return admno;
}
char* retstbno()
{
return stbno;
}
int rettoken()
{
return token;
}
33
void addtoken()
{token=1;}
void resettoken()
{token=0;}
};
fstream fp,fp1;
book bk;
student st;
void write_book()
{
char ch;
fp.open("book.dat",ios::out|ios::app);
do
{
clrscr();
34
bk.create_book();
fp.write((char*)&bk,sizeof(book));
cout<<"\n\nDo you want to add more record..(y/n?): ";
cin>>ch;
}while(ch=='y'||ch=='Y');
fp.close();
}
void write_student()
{
char ch;
fp.open("student.dat",ios::out|ios::app);
do
{
st.create_student();
fp.write((char*)&st,sizeof(student));
cout<<"\n\ndo you want to add more record..(y/n?): ";
cin>>ch;
}while(ch=='y'||ch=='Y');
fp.close();
}
void display_spb(char n[])
{
cout<<"\nBOOK DETAILS\n";
int flag=0;
35
fp.open("book.dat",ios::in);
while(fp.read((char*)&bk,sizeof(book)))
{
if(strcmpi(bk.retbno(),n)==0)
{
bk.show_book();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"\n\nBook does not exist";
getch();
}
void display_sps(char n[])
{
cout<<"\nSTUDENT DETAILS\n";
int flag=0;
fp.open("student.dat",ios::in);
while(fp.read((char*)&st,sizeof(student)))
{
if((strcmpi(st.retadmno(),n)==0))
{
36
st.show_student();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"\n\nStudent does not exist";
getch();
}
void modify_book()
{
char n[6];
int found=0;
clrscr();
cout<<"\n\nMODIFY BOOK REOCORD.... ";
cout<<"\n\nEnter The book no. of The book";
cin>>n;
fp.open("book.dat",ios::in|ios::out);
while(fp.read((char*)&bk,sizeof(book)) && found==0)
{
if(strcmpi(bk.retbno(),n)==0)
{
bk.show_book();
37
cout<<"\nEnter The New Details of book"<<endl;
bk.modify_book();
int pos=-1*sizeof(bk);
fp.seekp(pos,ios::cur);
fp.write((char*)&bk,sizeof(book));
cout<<"\n\nRecord Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\nRecord Not Found ";
getch();
}
void modify_student()
{
char n[6];
int found=0;
clrscr();
cout<<"\n\nMODIFY STUDENT RECORD... ";
cout<<"\n\nEnter The admission no. of The student";
cin>>n;
fp.open("student.dat",ios::in|ios::out);
38
while(fp.read((char*)&st,sizeof(student)) && found==0)
{
if(strcmpi(st.retadmno(),n)==0)
{
st.show_student();
cout<<"\nEnter The New Details of student"<<endl;
st.modify_student();
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
fp.write((char*)&st,sizeof(student));
cout<<"\n\nRecord Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\nRecord Not Found ";
getch();
}
void delete_student()
{
char n[6];
int flag=0;
39
clrscr();
cout<<"\n\n\nDELETE STUDENT...";
cout<<"\n\nEnter The admission no. of the Student You Want To Delete
: ";
cin>>n;
fp.open("student.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&st,sizeof(student)))
{
if(strcmpi(st.retadmno(),n)!=0)
fp2.write((char*)&st,sizeof(student));
else
flag=1;
}
fp2.close();
fp.close();
remove("student.dat");
rename("Temp.dat","student.dat");
if(flag==1)
cout<<"\n\nRecord Deleted ..";
else
40
cout<<"\n\nRecord not found";
getch();
}
void delete_book()
{
char n[6];
clrscr();
cout<<"\n\n\nDELETE BOOK ...";
cout<<"\n\nEnter The Book no. of the Book You Want To Delete : ";
cin>>n;
fp.open("book.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&bk,sizeof(book)))
{
if(strcmpi(bk.retbno(),n)!=0)
{
fp2.write((char*)&bk,sizeof(book));
}
}
fp2.close();
fp.close();
41
remove("book.dat");
rename("Temp.dat","book.dat");
cout<<"\n\nRecord Deleted ..";
getch();
}
void display_alls()
{
clrscr();
fp.open("student.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN ";
getch();
return;
}
cout<<"\n\nSTUDENT LIST\n\n";
cout<<"==============================================
====================\n";
cout<<"Admission No."<<setw(15)<<"Name"<<setw(20)<<"Book
Issued\n";
cout<<"==============================================
====================\n";
42
while(fp.read((char*)&st,sizeof(student)))
{
st.report();
}
fp.close();
getch();
}
void display_allb()
{
clrscr();
fp.open("book.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN ";
getch();
return;
}
cout<<"\n\nBook LIST\n\n";
cout<<"==============================================
===========================\n";
43
cout<<"Book Number"<<setw(25)<<"Book
Name"<<setw(35)<<"Author\n";
cout<<"==============================================
===========================\n";
while(fp.read((char*)&bk,sizeof(book)))
{
bk.report();
}
fp.close();
getch();
}
void book_issue()
{
char sn[6],bn[6];
int found=0,flag=0;
clrscr();
cout<<"\n\nBOOK ISSUE ...";
cout<<"\n\nEnter The student's admission no.: ";
cin>>sn;
fp.open("student.dat",ios::in|ios::out);
fp1.open("book.dat",ios::in|ios::out);
44
while(fp.read((char*)&st,sizeof(student)) && found==0)
{
if(strcmpi(st.retadmno(),sn)==0)
{
found=1;
if(st.rettoken()==0)
{
cout<<"\n\nEnter the book no.: ";
cin>>bn;
while(fp1.read((char*)&bk,sizeof(book))&& flag==0)
{
if(strcmpi(bk.retbno(),bn)==0)
{
bk.show_book();
flag=1;
st.addtoken();
st.getstbno(bk.retbno());
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
fp.write((char*)&st,sizeof(student));
cout<<"\n\nBook issued
successfully\n\nPlease Note: Return within 15 days";
}
}
45
if(flag==0)
cout<<"\nBook no does not exist";
}
else
cout<<"\nYou have not returned the last book ";
}
}
if(found==0)
cout<<"\nStudent record not exist...";
getch();
fp.close();
fp1.close();
}
void book_deposit()
{
char sn[6];
int found=0,flag=0,day,fine;
clrscr();
cout<<"\n\nBOOK DEPOSIT ...";
cout<<"\n\nEnter The student’s admission no.: ";
cin>>sn;
fp.open("student.dat",ios::in|ios::out);
46
fp1.open("book.dat",ios::in|ios::out);
while(fp.read((char*)&st,sizeof(student)) && found==0)
{
if(strcmpi(st.retadmno(),sn)==0)
{
found=1;
if(st.rettoken()==1)
{
while(fp1.read((char*)&bk,sizeof(book))&& flag==0)
{
if(strcmpi(bk.retbno(),st.retstbno())==0)
{
bk.show_book();
flag=1;
cout<<"\n\nBook deposited in no. of days: ";
cin>>day;
if(day>15)
{
fine=(day-15)*1;
cout<<"\n\nFine has to deposited Rs. "<<fine;
}
st.resettoken();
int pos=-1*sizeof(st);
fp.seekp(pos,ios::cur);
47
fp.write((char*)&st,sizeof(student));
cout<<"\n\nBook deposited successfully";
}
}
if(flag==0)
cout<<"\nBook no. does not exist";
}
else
cout<<"\nNo book is issued..please check!!";
}
}
if(found==0)
cout<<"\nStudent record not exist...";
getch();
fp.close();
fp1.close();
}
void intro()
{
clrscr();
gotoxy(35,1);
cout<<"LIBRARY";
48
gotoxy(34,2);
cout<<"MANAGEMENT";
gotoxy(35,3);
cout<<"SYSTEM";
cout<<"\n\nMADE BY : ASAD,JAYANTH";
cout<<"\n\nSCHOOL : PRESIDENCY SCHOOL BANGALORE
EAST";
cout<<"\n\n\n\n\n\n\nPress any key to continue......";
getch();
}
void admin_menu()
{
clrscr();
int ch2;
cout<<"\t\t\t\tADMINISTRATOR MENU";
cout<<"\n\n1.CREATE STUDENT RECORD";
cout<<"\n2.DISPLAY ALL STUDENTS RECORD";
cout<<"\n3.DISPLAY SPECIFIC STUDENT RECORD ";
cout<<"\n4.MODIFY STUDENT RECORD";
cout<<"\n5.DELETE STUDENT RECORD";
cout<<"\n6.ADD BOOKS ";
cout<<"\n7.DISPLAY ALL BOOKS ";
cout<<"\n8.DISPLAY SPECIFIC BOOK ";
cout<<"\n9.MODIFY BOOK ";
49
cout<<"\n10.DELETE BOOK ";
cout<<"\n11.BACK TO MAIN MENU";
cout<<"\nPlease Enter Your Choice (1-11): ";
cin>>ch2;
switch(ch2)
{
case 1: clrscr();
write_student();break;
case 2: display_alls();break;
case 3:
char num[6];
clrscr();
cout<<"\n\nPlease Enter The Admission No.: ";
cin>>num;
display_sps(num);
break;
case 4: modify_student();break;
case 5: delete_student();break;
case 6: clrscr();
write_book();break;
case 7: display_allb();break;
case 8: {
char num[6];
clrscr();
50
cout<<"\n\nPlease Enter The book No. ";
cin>>num;
display_spb(num);
break;
}
case 9: modify_book();break;
case 10: delete_book();break;
case 11: return;
default:cout<<"\a";
}
admin_menu();
}
void main()
{ int counter=0;;
char ch,c[10],ps[]="bestproject2019";
int choice;
int i;
intro();
do
{
clrscr();
m:cout<<"\t\t\t\t MAIN MENU";
51
cout<<"\n\n\n01. BOOK ISSUE";
cout<<"\n02. BOOK DEPOSIT";
cout<<"\n03. ADMINISTRATOR MENU";
cout<<"\n04. EXIT";
cout<<"\nPlease Select Your Option (1-4): ";
cin>>choice;
switch(choice)
{
case 1:clrscr();
book_issue();
break;
case 2:book_deposit();
break;
case 3: clrscr();
cout<<"\nEnter your password:";
for(i=0;i<15;i++)
{
c[i]=getch();
cout<<"*";
}
for(i=0;i<15;i++)
{
if(c[i]==ps[i])
{counter=1;}
52
else
{counter=0;
break;
}
}
if(counter==1)
{ admin_menu();}
else
{
cout<<"\n\n\n\n\t\t\t********Access Denied********";
goto m;
}
break;
case 4:exit(0);
default :cout<<"\a";
}
}while(ch!='4');
}
OUTPUT
53
MAIN SCREEN
MAIN MENU
ADMIN MENU
54
CREATE STUDENT
55
DISPLAY ALL STUDENTS RECORD
56
MODIFY STUDENT RECORD
57
ADD BOOKS
58
DISPLAY SPECIFIC BOOK RECORD
MODIFY BOOK
59
DELETE BOOK
BOOK ISSUE
60
BOOK DEPOSIT
61
FUTURE ENHANCEMENTS
Date function to be used to calculate the fine.
Barcode Reader to scan the books and enter them automatically.
Store number of copies of a book.
Create fine account for students and allow to borrow multiple books.
62
BIBLIOGRAPHY
Computer Science with C++- Sumita Arora
Cbseportal.com
Cbsetoday.c
63