Computer Science Project: Book Shop Management
Computer Science Project: Book Shop Management
SUBMITTED
BY
KAMESH S
1|Page
C++ OVERVIEW
C++ is a superset of C, and that virtually any legal C program is a legal C++
program.
Note: A programming language is said to use static typing when type checking
is performed during compiled-time as opposed during run-time.
Encapsulation
Data hiding
Inheritance
2|Page
The purpose of learning a programming language is to become a better
programmer; that is, to become more effective at designing and implementing
new systems and at maintaining old ones.
C++ supports a variety of programming styles. You can write in the style of
Fortran, C, Smalltalk, etc., in any language. Each style can achieve its aims
effectively while maintaining runtime and space efficiency.
Uses of C++:
C++ is being highly used to write device drivers and other software that rely on
direct manipulation of hardware under real-time constraints.
C++ is widely used for teaching and research because it is clean enough for
successful teaching of basic concepts.
Anyone who has used either an Apple Macintosh or a PC running Windows has
indirectly used C++ because the primary user interfaces of these systems are
written in C++.
3|Page
SYNOPSIS
In this project the menu of the shop contains “To purchase books by the shop
management, to show all the books for the customer reference, to check the
availability of that particular book by searching by its number, to modify the
book, to delete a particular book by searching by its number.
So, the management was fully responsible and this was mainly made for the
benefit of the customers to properly select their book and if any defect in that
the main purpose of the management is that to replace it as well as to check if
any defects in the available stock of books and delete that.
So, after all the procedures made by the shop management then the book is
given to the customer with a cash memo to them and the main duty to duly hand
it over to the customers because in case of any defect, customers can get
replaced the defect one with new one. The customers get other major benefits
also.
4|Page
SYSTEM REQUIREMENTS
Hardware:
Memory: 8 GB RAM.
Software:
5|Page
HEADER FILES
The C++ standard library contains files containing the standard functions that
your program may use.
The header file contains definition of function and variables, which is imported
or used into any C++ program by using the pre-processer directive.
1.iostream.h:
C++ input/output streams are primarily defined by iostream, a header file that is
part of the C++ standard library (the name stands for Input/Output Stream).
2.conio.h:
3.fstream.h:
Classes dealing with the input and output of data are called stream classes....
and objects of the class ofstream deal with output files. Objects fstream deal
6|Page
with files that can one can write to and read from. ofstream, ifstream, and
fstream are subclasses that are defined in the include file fstream.h.
4.stdio.h:
It is the header file for standard input and output. This is useful for getting the
input from the user (Keyboard) and output result text to the monitor(screen).
5.string.h:
It is the header in the C standard library for the C programming language which
contains macro definitions, constants and declarations of functions and types
used not only for string handling but also various memory handling functions;
the name is thus something of a misnomer.
6.iomanip.h:
7.process.h:
7|Page
CLASSES
A class that inherits another class is known as child class, it is also known as
derived class or subclass.
1.class book:
It is the base class which stores two data members (book_name, book_number)
in public visibility mode of data type char.
2.class shop:
It is the derived class which inherits the base class (class book) in public
visibility mode and also contains two data members (author_name, book_num).
8|Page
FUNCTIONS
A function is a block of code which only runs when it is called. You can pass
data, known as parameters, into a function. Functions are used to perform
certain actions, and they are important for reusing code: Define the code once,
and use it many times.
1.get_book_details ():
This function is used to get the information about the book that the buyer is
going to purchase such as book name, author name, book number and number
of copies.
2.modify_book ():
This function is used to modify the details of the existing book with new
information entered by the user.
9|Page
3.display_a_book ():
This function is used to check the availability of the the book that the user
requires.
4.delete_book ():
This function is used to delete the record of the book once it is been purchased.
5.show_book ():
This function is used to display the information of the book such as book name,
book number, author name and number of copies to the user.
6.write_book ():
This function is used to add newly purchased books information to the record.
7.display_allb ():
This function is used to display information about all the books available in the
store.
10 | P a g e
SOURCE CODE
#include<fstream.h>
#include<conio.h>
#include<string.h>
#include<iomanip.h>
#include<iostream.h>
#include<stdio.h>
#include<process.h>
class book
public:
char book_number[30];
11 | P a g e
char book_name[50];
};
char author_name[20];
int num_copies;
public:
void get_book_details()
cin>>book_number;
cin.ignore();
cin.getline(book_name,50);
cin.ignore();
cin.getline(author_name,50);
cin>>num_copies;
void show_book()
12 | P a g e
{
cout<<"\nCOPIES : "<<num_copies;
void modify_book()
cin.ignore();
cin.getline(book_name,50);
cin.ignore();
cin.getline(author_name,50);
cin>>num_copies;
char* getbooknumber()
return book_number;
13 | P a g e
void report()
{cout<<book_number<<setw(30)<<book_name<<setw(30)<<author_name<<s
etw(30)<<num_copies<<endl;}
};
fstream fp;
shop bk;
void write_book()
clrscr();
int more_or_main;
fp.open("book.dat",ios::out|ios::app);
do
bk.get_book_details();
fp.write((char*)&bk,sizeof(book));
cout<<"Enter: ";
cin>>more_or_main;
}while(more_or_main == 1);
fp.close();
14 | P a g e
void display_a_book(char n[])
clrscr();
cout<<"\nBOOK DETAILS\n";
int check=0;
fp.open("book.dat",ios::in);
while(fp.read((char*)&bk,sizeof(book)))
if(strcmpi(bk.getbooknumber(),n)==0)
bk.show_book();
check=1;
fp.close();
if(check==0)
getch();
void modify_book()
15 | P a g e
clrscr();
char n[20];
int found=0;
cout<<"\n\n\tMODIFY BOOK";
cin>>n;
fp.open("book.dat",ios::in|ios::out);
if(strcmpi(bk.getbooknumber(),n)==0)
bk.show_book();
bk.modify_book();
int pos=-1*sizeof(bk);
fp.seekp(pos,ios::cur);
fp.write((char*)&bk,sizeof(book));
found=1;
fp.close();
16 | P a g e
if(found==0)
getch();
void delete_book()
clrscr();
char n[20];
int flag=0;
cout<<"\n\n\n\tDELETE BOOK";
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.getbooknumber(),n)!=0)
fp2.write((char*)&bk,sizeof(book));
17 | P a g e
else
flag=1;
fp2.close();
fp.close();
remove("book.dat");
rename("Temp.dat","book.dat");
if(flag==1)
else
getch();
void display_allb()
clrscr();
fp.open("book.dat",ios::in);
if(!fp)
getch();
18 | P a g e
cout<<"\n\n\t\tBook LIST\n\n";
cout<<"===================================================
=========================================\n";
cout<<"Book Number"<<setw(20)<<"Book
Name"<<setw(25)<<"Author"<<setw(25)<<"Copies"<<endl;
cout<<"===================================================
=========================================\n";
while(fp.read((char*)&bk,sizeof(book)))
bk.report();
fp.close();
getch();
void intro()
clrscr();
cout<<"\t\t\t\t*\t*";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t***\t***";
cout<<"\t\t\t\t****\t****";
cout<<"\t\t\t\t*****\t*****";
19 | P a g e
cout<<"\t\t\t\t******\t******";
cout<<"\t\t\t\t*******\t*******";
cout<<"\t\t\t\t*******\t*******";
cout<<"\t\t\t\t******\t******";
cout<<"\t\t\t\t*****\t*****";
cout<<"\t\t\t\t****\t****";
cout<<"\t\t\t\t***\t***";
cout<<"\t\t\t\t**\t**";
cout<<"\t\t\t\t*\t*";
void main()
int option = 0;
for(;;)
intro();
cout<<"\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@";
cout<<"\n\t\tPress 1 to TO BUY";
20 | P a g e
cout<<"\n\t\tPress 5 to DELETE BOOKS";
cout<<"\n\t\tPress 6 to Exit";
cout<<"\n\t\t@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@@@@@@@@@@@@@@\n";
cout<<"\n\t\tOption: ";
cin>>option;
switch(option)
case 1: clrscr();
write_book();
break;
case 2: display_allb();
break;
case 3:
char num[20];
clrscr();
cin>>num;
display_a_book(num);
break;
case 4: modify_book();break;
case 5: delete_book();break;
21 | P a g e
case 6: exit(0);
break;
default:cout<<"\a";
OUTPUT
22 | P a g e
23 | P a g e
24 | P a g e
25 | P a g e
26 | P a g e
27 | P a g e
28 | P a g e
29 | P a g e
CONCLUSION
The following output drawn out of the project made would be very helpful for
the readers in this modern world for purchasing the book correctly and more
easily. The program is mainly created for the benefits of costumers. The
software is developed in modular approach for easy adaptability. It is capable of
accepting any changes with little alterations made in it.
30 | P a g e
FUTURE ENHANCEMENT
1.Any educational institute can make use of it for providing information about
author, content of available book in there library.
3.It can be used in type of book shop for managing all the sale and purchasing
activity and managing the data records related to book house.
31 | P a g e
BIBLIOGRAPHY
3.www.cppforschool.com
4.www.studiestoday.com
5.www.geeksforgeeks.com
32 | P a g e
33 | P a g e