This document describes Divyanshu Kumar's class 12 investigatory project on a bank management system created using C++. The project uses object-oriented programming concepts like classes, objects, inheritance and polymorphism to develop a program to manage bank accounts stored in a binary file. The program allows users to perform operations like creating new accounts, depositing and withdrawing amounts, checking balances and listing all accounts. The source code and outputs of the program are included along with an index and acknowledgements section.
2. KENDRIYA VIDYALAYA NO 2
NAUSENABAGH, VISAKHAPATNAM
DEPARTMENT OF COMPUTER
SCIENCE
CERTIFICATE
This is to certify that DIVYANSHU
KUMAR of Class XII A has prepared the
investigatory project entitled “BANK
MANAGEMENT SYSTEM”. The project is the
result of his efforts and endeavors. The report is
found worthy of acceptance as final project
report. He has prepared the report under my
guidance.
3. PGT (COMPUTER SCIENCE)
D E C L A R A T I O N
I hereby declare that the project work
entitled “BANK MANAGEMENT SYSTEM”,
submitted to Department of Computer
Science, Kendriya Vidyalaya No. 2,
Nausenabaugh, Visakhapatnam is prepared
by me.
DIVYANSHU KUMAR
Class: XII A
Cbse roll no-
4. ACKNOWLEDGEMENT
Through this acknowledgement I express my sincere gratitude to
all those people who have been associated with the project and
helped meto makeit a worthwhileexperience.
Iextend my thanksto ourprincipal Mr.NishikantAggarwal
and (PGTComputerScience) fortheir
valuable guidance.
I would like to express my gratitude towards my parents for their
co-operation and encouragement which helped me to complete
this project.
6. INDEX
3. Intro. To Data File
Handling
4. About The
Program
5. Header File Used
6. Source Code
7. Output
8. Bibliography
7. INTRODUCTION
C++ is a statically typed, compiled, general purpose, case-sensitive, free-
form programming language that supports procedural, object-oriented,
and generic programming. C++ is regarded as a middle-level language,
as it comprises a combination of both high-level and low-level language
features. C++ was developed by Bjarne Stroustrupstarting in 1979 at Bell
Labs in Murray Hill, New Jersey as an enhancement to the C language
and originally named C with Classes but later it was renamed
C++ in 1983.C++ is a superset of C, and that virtually any legal C
program is a legal C++ program. The most important thing to do when
learning C++ is to focus on concepts and not get lost in language
technical details. C++ is used by hundreds of thousands of programmers
in essentially every application domain. 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 cleaning enough for successful teaching of
8. basic concepts. Anyone who has used either an apple Macintosh or a PC
running windows has directly used C++ because the primary user
interfaces of these systemare written in C++.
INTRODUCTION TO OBJECT ORIENTED
PROGRAMMING CONCEPTS
Object Oriented Programming is a programming style that is
associated with the concept of Class, Objects and various other
concepts revolving around these two, like Inheritance,
Polymorphism, Abstraction, Encapsulation etc.
Basic OOPS concepts in c++
Here we will try to explain all the OOP concepts through this
example and later we will have the technical definitons for all
this.
Class
Here we can take Human Being as a class. A class is a blueprint
for any functional entity which defines its properties and its
functions. Like Human Being, having body parts, and performing
various actions.
Inheritance
Considering HumanBeing a class, which has properties like
hands, legs, eyes etc, and functions like walk, talk, eat, see etc.
Male and Female are also classes, but most of the properties and
9. functions are included in HumanBeing, hence they can inherit
everything from class HumanBeing using the concept of
Inheritance.
Abstraction
Abstraction means, showcasing only the required things to the
outside world while hiding the details. Continuing our example,
Human Being's can talk, walk, hear, eat, but the details are hidden
from the outside world. We can take our skin as the Abstraction
factor in our case, hiding the inside mechanism.
Encapsulation
This concept is a little tricky to explain with our example. Our
Legs are binded to help us walk. Our hands, help us hold things.
This binding of the properties to functions is called
Encapsulation.
Polymorphism
Polymorphism is a concept, which allows us to redefine the way
something works, by either changing how it is done or by
changing the parts using which it is done. Both the ways have
different terms for them.
If we walk using our hands, and not legs, here we will change the
parts used to perform something. Hence this is called
Overloading.
And if there is a defined way of walking, but I wish to walk
differently, but using my legs, like everyone else. Then I can walk
like I want, this will be called as Overriding.
OOPS Concept Definitions
10. Now, let us discuss some of the main features of Object Oriented
Programming which you will be using in C++(technically).
Objects
Classes
Abstraction
Encapsulation
Inheritance
Overloading
Exception Handling
Objects
Objects are the basic unit of OOP. They are instances of class,
which have data members and uses various member functions to
perform tasks.
Class
It is similar to structures in C language. Class can also be defined
as user defined data type but it also contains functions in it. So,
class is basically a blueprint for object. It declare & defines what
data variables the object will have and what operations can be
performed on the class's object.
Abstraction
11. Abstraction refers to showing only the essential features of the
application and hiding the details. In C++, classes provide
methods to the outside world to access & use the data variables,
but the variables are hidden from direct access. This can be done
access specifiers.
Encapsulation
It can also be said data binding. Encapsulation is all about binding
the data variables and functions together in class.
Inheritance
Inheritance is a way to reuse once written code again and again.
The class which is inherited is called base calls & the class which
inherits is called derived class. So when, a derived class inherits a
base class, the derived class can use all the functions which are
defined in base class, hence making code reusable.
It is a feature, which lets us create functions with same name but
different arguments, which will perform differently. That is
function with same name, functioning in different way. Or, it also
allows us to redefine a function to provide its new definition. You
will learn how to do this in details soon in coming lessons.
Exception Handling
Exception handling is a feature of OOP, to handle unresolved
exceptions or errors produced at runtime from the outside world.
We can take our skin as the Abstraction factor in our case, hiding
the inside mechanism.
INTRODUTION TO DATA FILE
12. HANDLING
Most computersprograms workwith files. This is because
files help in storing information permanently. A fileis itselfa
bunchofbytesstored onsome storagedevice like tape,or
magnetic disk, etc.
In C++, file input/outputfacilities are implemented
throughacomponentheaderfile pf C++ standardlibrary.
This headeris fstream.h.
In C++, a file, atlowest level, is interpretedsimply as a
sequence,or streamof bytes.One aspectof the file I/O
library managesthetransferof thesebytes.
The fstream library predefines a set of operations for
handling file related input and output. It defines certain
classes thathelpone performfile input andoutput.
13. ABOUT THE PROGRAM
The project “Bank Management System” has been
developed as a very understandable Databaseof methods
that can be created and handle easily. When you add a
person acc. details to the database, the details is added
automatically and settled in the binary file.
The project aimed to create an easy database which can be
handled and created easily. Generally, the database is being
a master file that possessesthe tabular format of person’s
acc. details, the sub menu for the account like acc. no. ,
deposit, name and menu option return.
14. HEADER FILES USED IN
PROGRAM
fstream.h – For file handling, cin,
cout.
stdio.h – For standard I/O
operations.
process.h – For exit() function.
iomanip.h – For setw() function.
conio.h – For clrscr() & getch()
function.
ctype.h – For toupper() function.
15. SOURCE CODE
//***************************************************************
// HEADER FILE USED IN PROJECT
//****************************************************************
#include<fstream.h>
#include<ctype.h>
#include<iomanip.h>
#include<conio.h>
#include<stdio.h>
//***************************************************************
// CLASS USED IN PROJECT
//****************************************************************
class account
{
int acno;
char name[50];
int deposit;
char type;
public:
void create_account(); //function to get data from user
void show_account(); //function to show data on screen
void modify(); //function to get new data from user
void dep(int); //function to accept amount and add to balance amount
void draw(int); //function to accept amount and subtract from balance
amount
void report(); //function to show data in tabular format
int retacno(); //function to return account number
16. int retdeposit(); //function to return balance amount
char rettype(); //function to return type of account
}; //class ends here
void account::create_account()
{
cout<<"nEnter The account No.";
cin>>acno;
cout<<"nnEnter The Name of The account Holder : ";
gets(name);
cout<<"nEnter Type of The account (C/S) : ";
cin>>type;
type=toupper(type);
cout<<"nEnter The Initial amount(>=500 for Saving and >=1000 for current
) : ";
cin>>deposit;
cout<<"nnnAccount Created..";
}
void account::show_account()
{
cout<<"nAccount No. : "<<acno;
cout<<"nAccount Holder Name : ";
cout<<name;
cout<<"nType of Account : "<<type;
cout<<"nBalance amount : "<<deposit;
}
void account::modify()
{
cout<<"nThe account No."<<acno;
cout<<"nnEnter The Name of The account Holder : ";
gets(name);
cout<<"nEnter Type of The account (C/S) : ";
cin>>type;
type=toupper(type);
cout<<"nEnter The amount : ";
cin>>deposit;
}
void account::dep(int x)
{
deposit+=x;
}
void account::draw(int x)
{
deposit-=x;
17. }
void account::report()
{
cout<<acno<<setw(10)<<" "<<name<<setw(10)<<"
"<<type<<setw(6)<<deposit<<endl;
}
int account::retacno()
{
return acno;
}
int account::retdeposit()
{
return deposit;
}
char account::rettype()
{
return type;
}
//***************************************************************
// function declaration
//****************************************************************
void write_account(); //function to write record in binary file
void display_sp(int); //function to display account details given by user
void modify_account(int); //function to modify record of file
void delete_account(int); //function to delete record of file
void display_all(); //function to display all account details
void deposit_withdraw(int, int); // function to desposit/withdraw amount for given
account
void intro(); //introductory screen function
//***************************************************************
// THE MAIN FUNCTION OF PROGRAM
//****************************************************************
int main()
{
char ch;
int num;
clrscr();
intro();
do
{
clrscr();
18. cout<<"nnntMAIN MENU";
cout<<"nnt01. NEW ACCOUNT";
cout<<"nnt02. DEPOSIT AMOUNT";
cout<<"nnt03. WITHDRAW AMOUNT";
cout<<"nnt04. BALANCE ENQUIRY";
cout<<"nnt05. ALL ACCOUNT HOLDER LIST";
cout<<"nnt06. CLOSE AN ACCOUNT";
cout<<"nnt07. MODIFY AN ACCOUNT";
cout<<"nnt08. EXIT";
cout<<"nntSelect Your Option (1-8) ";
cin>>ch;
clrscr();
switch(ch)
{
case '1':
write_account();
break;
case '2':
cout<<"nntEnter The account No. : "; cin>>num;
deposit_withdraw(num, 1);
break;
case '3':
cout<<"nntEnter The account No. : "; cin>>num;
deposit_withdraw(num, 2);
break;
case '4':
cout<<"nntEnter The account No. : "; cin>>num;
display_sp(num);
break;
case '5':
display_all();
break;
case '6':
cout<<"nntEnter The account No. : "; cin>>num;
delete_account(num);
break;
case '7':
cout<<"nntEnter The account No. : "; cin>>num;
modify_account(num);
break;
case '8':
cout<<"nntThanks for using bank managemnt system";
break;
default :cout<<"a";
}
getch();
}while(ch!='8');
return 0;
}
19. //***************************************************************
// function to write in file
//****************************************************************
void write_account()
{
account ac;
ofstream outFile;
outFile.open("account.dat",ios::binary|ios::app);
ac.create_account();
outFile.write((char *) &ac, sizeof(account));
outFile.close();
}
//***************************************************************
// function to read specific record from file
//****************************************************************
void display_sp(int n)
{
account ac;
int flag=0;
ifstream inFile;
inFile.open("account.dat",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
cout<<"nBALANCE DETAILSn";
while(inFile.read((char *) &ac, sizeof(account)))
{
if(ac.retacno()==n)
{
ac.show_account();
flag=1;
}
}
inFile.close();
if(flag==0)
cout<<"nnAccount number does not exist";
}
//***************************************************************
// function to modify record of file
//****************************************************************
void modify_account(int n)
20. {
int found=0;
account ac;
fstream File;
File.open("account.dat",ios::binary|ios::in|ios::out);
if(!File)
{
cout<<"File could not be open !! Press any Key...";
return;
}
while(File.read((char *) &ac, sizeof(account)) && found==0)
{
if(ac.retacno()==n)
{
ac.show_account();
cout<<"nnEnter The New Details of account"<<endl;
ac.modify();
int pos=(-1)*sizeof(account);
File.seekp(pos,ios::cur);
File.write((char *) &ac, sizeof(account));
cout<<"nnt Record Updated";
found=1;
}
}
File.close();
if(found==0)
cout<<"nn Record Not Found ";
}
//***************************************************************
// function to delete record of file
//****************************************************************
void delete_account(int n)
{
account ac;
ifstream inFile;
ofstream outFile;
inFile.open("account.dat",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
outFile.open("Temp.dat",ios::binary);
inFile.seekg(0,ios::beg);
while(inFile.read((char *) &ac, sizeof(account)))
{
if(ac.retacno()!=n)
21. {
outFile.write((char *) &ac, sizeof(account));
}
}
inFile.close();
outFile.close();
remove("account.dat");
rename("Temp.dat","account.dat");
cout<<"nntRecord Deleted ..";
}
//***************************************************************
// function to display all accounts deposit list
//****************************************************************
void display_all()
{
account ac;
ifstream inFile;
inFile.open("account.dat",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! Press any Key...";
return;
}
cout<<"nnttACCOUNT HOLDER LISTnn";
cout<<"====================================================
n";
cout<<"A/c no. NAME Type Balancen";
cout<<"====================================================
n";
while(inFile.read((char *) &ac, sizeof(account)))
{
ac.report();
}
inFile.close();
}
//***************************************************************
// function to deposit and withdraw amounts
//****************************************************************
void deposit_withdraw(int n, int option)
{
int amt;
int found=0;
account ac;
fstream File;
File.open("account.dat", ios::binary|ios::in|ios::out);
if(!File)
22. {
cout<<"File could not be open !! Press any Key...";
return;
}
while(File.read((char *) &ac, sizeof(account)) && found==0)
{
if(ac.retacno()==n)
{
ac.show_account();
if(option==1)
{
cout<<"nntTO DEPOSITE AMOUNT ";
cout<<"nnEnter The amount to be deposited : ";
cin>>amt;
ac.dep(amt);
}
if(option==2)
{
cout<<"nntTO WITHDRAW AMOUNT ";
cout<<"nnEnter The amount to be withdraw : ";
cin>>amt;
int bal=ac.retdeposit()-amt;
if((bal<500 && ac.rettype()=='S') || (bal<1000 &&
ac.rettype()=='C'))
cout<<"Insufficience balance";
else
ac.draw(amt);
}
int pos=(-1)* sizeof(ac);
File.seekp(pos,ios::cur);
File.write((char *) &ac, sizeof(account));
cout<<"nnt Record Updated";
found=1;
}
}
File.close();
if(found==0)
cout<<"nn Record Not Found ";
}
//***************************************************************
// INTRODUCTION FUNCTION
//****************************************************************
void intro()
{
cout<<"nnnt BANK MANAGEMENT SYSTEM n";
cout<<"t -------------------------------";
23. cout<<"nn MADE BY : DIVYANSHU & DEEPAK ";
cout<<"nn SCHOOL : Kendriya Vidyalaya No.2,NSB,Vizag”;
getch();
}
//***************************************************************
// END OF PROJECT
//***************************************************************
OUTPUT OF THE
PROGRAM