Professional Documents
Culture Documents
C New
C New
On
BANKING
SYSTEM
Session- 2015-16
BY
NAYAN SINGHAI
SAURABH PAWAR
Under the guidance of
Mr. N. Chandrasekhar
For the partial fulfillment of
AISSC,CBSE,NewDelhi
Submitted to
Jawaharlal Nehru School
Habibganj BHEL, Bhopal
Acknowledgement
I Would like to thank my C++ teacher
Mr. N. Chandrasekhar For all that they
have taught me and their guidance for making this
program .I would also like to thank Mrs. Lalita
Chatterjee for her great help. I would also like
to thank my partner Nayan Singhai and my
parents to support me and encourage me to do
this work.
- Saurabh Pawar
Certificate
This is to certify that Nayan Singhai and
Saurabh Pawar of class 12th has successfully
completed the project file with the help of C++
programming under my guidance and supervision. I am
satisfied with their initiatives and the efforts for the
completion of this project file as a part of curriculum of
CBSE 12th examination.
Date:-
Place:- Bhopal
______________ ________________
Mr. N. Chandrasekhar
C
CC ontents
ontents
ontents
1]. INTRODUCTION TO C+
+
2]. OBJECT ORIENTED
PROGRAMMING
3]. DATA FILE HANDLING
4]. INTRODUCTION TO THE
PROJECT
5]. DOCUMENTATION OF
PROJECT
6]. ALGORITHM OF THE
PROJECT
7]. C++ SOURCE CODE
8]. SAMPLE OUTPUT
9]. BIBLIOGRAPHY
INTRODUCTION TO C++
C++ is a general purpose programming language with high level and low level
capabilities. It is statically typed, free form, multi paradigm, usually complied
supporting procedural programming, data abstraction and object oriented
programming.
C++ is regarded as a mid level language. This indicates that C++
comprises of both high level and low level language features.
Dr. Boujrne Stroustrup developed C++ in 1979 at AT&T Bell Lables as an
enhancement to the 'C' programming language and had features from one of
the earliest object oriented languages Simula 67. He named it "C with Classes."
In 1983 it was renamed to C++. This name is credited to Rick Mascitti (mid
1983) and was first used in December, 1983. Earlier during the research
period, the developing language had been referred to as "new C", then "C with
classes." The final name stems from C's"++" operator (which increments the
value of variable) and a common naming convention of using "+" to indicate an
enhanced computer program. Even since its birth, C++ evolved to cope up with
the problems encountered by users and through discussion at AT&T.
However the maturation of C++ is attested by two events :
(i) The formation of an ANSI (American Nation Standard Institute) C++
Committee.
(ii) The Publication of the Annotated Reference Manual by Ellis and
Stroustrup.
The major reason behind the popularity of C++ is that it supports object
oriented technology, the latest in the software development and the most near
to the real world. "Object Oriented Technology is regarded as the ultimate
paradigm for the modeling of information, be that data or logic. C++ has now
shown to fulfill that goal.
C++ finds major implementation in G++, Microsoft Visual C++, Turbo C++ and
Borland C++ Builder.
OBJECT
ORIENTED
PROGRAMMIN
G
Object Oriented Programming has an approach that provides a way of
modularizing a program by creating partitioned memory for both data and
sections that can be used as templates for creating copies of such modules on
demand.
The object oriented approach views a problem in terms of objects involved
rather than procedures for doing it. Object is an identifiable entity with some
characters and behavior.
Organization of Date and Functions in OOP Programming:-
While programming using OOP approach, the characteristics of an object are
represented by its data and its behavior is represented by its functions
associated. Therefore in OOP programming object represents and entity that
can store data and has its interface through functions.
A group of objects that share common properties and relation-ship is called a
Class. A class defines the abstract characteristics of an object, including the
object's characteristics (data) and the object's behavior (functions).
Paradigm - Definition of OOP (Object Oriented Programming):-
The Object Oriented paradigm is the latest in the software development
and most adopted one in the developing projects of today. By paradigm one
means a way of thinking. It is the organizing principle of a program or an
approach to programming. We can define the OOP paradigm as -
"Decide which classes and objects are needed; provide a full set of
operations of each class."
1. Data abstraction
2. Data encapsulation
3. Modularity
4. Inheritance
5. Polymorphism
Data Abstraction:-
Abstraction is the concept of simplifying a real world concet into its
essential elements. It refers to the act of representing essential
features without including the background details or explanations.
The class has different access levels, which make some properties
and behaviours of the class available to the outside world while the
rest are hidden. Thus only relevant and essential information is
Passed to the user thus implementing the concept of data
abstraction.
Data Encapsulation:-
Encapsulation is the most fundamental concept of OOP. It is the way
of combining data and functions that operate on that data under a
single unit. Thus, the wrapping of the data and functions into a single
unit is called as Encapsulation. Encapsulation is just a way to
implement data abstraction.
When data and its functions are encapsulated, the data is hidden and
is safe from accidental alteration. Data cannot be accessed directly.
The only way to access the data is provided by the functions that are
combined along with the data.
Modularity:-
The act of partitioning a program into individual components, called
modules, is called Modularity.
Modules work hand in hand to achieve the goal of the program. A
module is a separate unit in itself. It is a set of related procedures
with the data they manipulate. It can be compiled separately through
it has connections with other modules. The justification for
modularity is that it reduces the complexity to some extent and it
creates a number of well-defined, documented boundaries within
the program.Thus, modularity is the property of a system that has
been decomposed into a set of cohesive and loosely coupled
modules.
Inheritance:-
Inheritance (OOP) is when an object or class is based on another
object (prototypal inheritance) or class (class-based inheritance),
using the same implementation (inheriting from an object or class)
specifying implementation to maintain the same behavior (realizing
an interface; inheriting behavior). It is a mechanism for code
reuse and to allow independent extensions of the original software
via public classes and interfaces. The relationships of objects or
classes through inheritance give rise to a hierarchy. Inheritance was
invented in 1967 for Simula.
Polymorphism:-
Polymorphism is the ability of a data ton take more then one form.
The concept of Polymorphism enables a message or data to be
processed in different ways. That is, the same operation is performed
in different ways depending upon the data being manipulated.
1) ios::in – It specifies that the file is capable of input . It opens file for
reading.
2) ios::out – this specifies that the file is capable of output.It opens the file
for writing .This also opens a file in ios::trunk mode by default/. This means
that an existing file is truncated when opened . that ids its previous contents
are discarded
3) ios::ate – This seeks to the end of the file upon opening of the file . I/O can
still occur anywhere within the file .
6) ios::no create – This causes the open() function to fail if the file
does not exit already. It will not create the new file with that name.
7) ios::noreplace – This causes the open() function to fail if the file is already
exist.
8) ios::binary – This causes the file to open in binary mode, where no
character translation occurs and hence it is easier to access.
The get() function is byte oriented, that is, it will read a byte of data.
The get() function has many forms. The commonly used ones are –
3) int get():
Prototype : istream & getline( char* buf, int num, char delim =’\n’);
This function is virtually identical to the get( buf.num.delim) version of get().
The getline() function also reasa the characters into a character array pointed
by buf until either num characters have been read or the character specified
by delim has been encountered. But the difference betweenget() and getline ()
is that getliine () reads and removes the delimiter character from the input
stream if it is encountered which is not done so by the get() function.
When you modify balance in the account it will show the total
amount in your account each time you add money to the
account.
And when you withdraw money it will take away the amount
withdraw from the balance that is in the account
DATAFILE : ACCOUNT.dat
SIZE OF PROGRAM : 11 Kb
ALGORITH
M
The program asks you to enter the choices 1-5
PROGRAM CODING
//**********************************************************
// HEADER FILE USED IN PROJECT
//**********************************************************
#include<iostream.h>
#include<fstream.h>
#include<ctype.h>
#include<iomanip.h>
#include<conio.h>
#include<stdio.h>
//**********************************************************
// CLASS USED IN PROJECT
//**********************************************************
class account
{ double si;
int acno;
char name[50];
double 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(double); //function to accept amount and add to balance
amount
void cdraw(double);
void sdraw(double,double); //function to accept amount and
subtract from balance amount
void account::create_account()
{
cout<<"\nEnter The account No. "<<char(16)<<" ";
cin>>acno;
account ac;
ifstream fin;
fin.open("account.dat",ios::binary|ios::in);
fin.read((char *) &ac, sizeof(account));
if(acno==ac.retacno())
{
cout<<"\n\n Account no. already exist";
cout<<"\n Try again with new account no.";
}
if(acno!=ac.retacno())
{
cout<<"\n\nEnter The Name of The account Holder "<<char(16)<<" ";
gets(name);
cout<<"\nEnter Type of The account (C/S)\n";
cout<<"(10 % interest rate on saving account) "<<char(16)<<" ";
cin>>type;
type=toupper(type);
cout<<"\nEnter The Initial amount(>=500 for Saving and >=1000
for current ) "<<char(16)<<" ";
cin>>deposit;
cout<<"\n\n\nAccount 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<<"\n\nEnter 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(double x)
{
deposit+=x;
}
void account::cdraw(double x)
{
deposit-=x;
}
void account::report()
{
cout<<acno<<setw(19)<<" "<<name<<setw(17)<<"
"<<type<<setw(25)<<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();
cout<<"\n\n\n\tMAIN MENU";
cout<<"\n\n\t01. NEW ACCOUNT";
cout<<"\n\n\t02. DEPOSIT AMOUNT";
cout<<"\n\n\t03. WITHDRAW AMOUNT";
cout<<"\n\n\t04. BALANCE ENQUIRY";
cout<<"\n\n\t05. ALL ACCOUNT HOLDER LIST";
cout<<"\n\n\t06. CLOSE AN ACCOUNT";
cout<<"\n\n\t07. MODIFY AN ACCOUNT";
cout<<"\n\n\t08. EXIT";
cout<<"\n\n\tSelect Your Option (1-8) ";
cin>>ch;
clrscr();
switch(ch)
{
case '1':
write_account();
break;
case '2':
cout<<"\n\n\tEnter The account No. : "; cin>>num;
deposit_withdraw(num, 1);
break;
case '3':
cout<<"\n\n\tEnter The account No. : "; cin>>num;
deposit_withdraw(num, 2);
break;
case '4':
cout<<"\n\n\tEnter The account No. : "; cin>>num;
display_sp(num);
break;
case '5':
display_all();
break;
case '6':
cout<<"\n\n\tEnter The account No. : "; cin>>num;
delete_account(num);
break;
case '7':
cout<<"\n\n\tEnter The account No. : "; cin>>num;
modify_account(num);
break;
case '8':
cout<<"\n\n\n\n\n\n\n\tThanks for using bank managemnt system";
break;
default :cout<<"\a";
}
getch();
}while(ch!='8');
return 0;
}
//**********************************************************
// function to write in file
//**********************************************************
void write_account()
{
account ac;
ofstream File;
File.open("account.dat",ios::binary|ios::app);
ac.create_account();
File.write((char *) &ac, sizeof(account));
File.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 DETAILS\n";
while(inFile.read((char *) &ac, sizeof(account)))
{
if(ac.retacno()==n)
{
ac.show_account();
flag=1;
}
}
inFile.close();
if(flag==0)
cout<<"\n\nAccount number does not exist";
}
//**********************************************************
// function to modify record of file
//**********************************************************
void modify_account(int n)
{
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<<"\n\nEnter 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<<"\n\n\t Record Updated";
found=1;
}
}
File.close();
if(found==0)
cout<<"\n\n 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)
{
outFile.write((char *) &ac, sizeof(account));
}
}
inFile.close();
outFile.close();
remove("account.dat");
rename("Temp.dat","account.dat");
cout<<"\n\n\tRecord 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<<"\n\n\t\t\t\tACCOUNT HOLDER LIST\n\n";
cout<<"========================================================
========================\n";
cout<<"A/c no. NAME TYPE
BALANCE";
cout<<"\n======================================================
==========================\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)
{
double amt;
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();
if(option==1)
{
cout<<"\n\n\tTO DEPOSITE AMOUNT ";
cout<<"\nEnter The amount to be deposited :";
cout<<char(16)<<" ";
cin>>amt;
ac.dep(amt);
}
if(option==2&&ac.rettype()=='S')
{
}
if(option==2&&ac.rettype()=='C')
{
cout<<"\n\n\tTO WITHDRAW AMOUNT ";
cout<<"\n\nEnter The amount to be withdraw :
";
cin>>amt;
ac.cdraw(amt);
}
int pos=(-1)* sizeof(ac);
File.seekp(pos,ios::cur);
File.write((char *) &ac, sizeof(account));
cout<<"\n\n\t Record Updated";
found=1;
}
}
File.close();
if(found==0)
cout<<"\n\n Record Not Found ";
}
//**********************************************************
// INTRODUCTION FUNCTION
//*********************************************************
void intro()
{
cout<<"\n\n\n\t\t\t\t BANKING";
cout<<"\n\n\t\t\t\tMANAGEMENT";
cout<<"\n\n\t\t\t\t SYSTEM";
cout<<"\n\n\n\n\t\tMADE BY : Nayan Singhai & Saurabh
Pawar ";
cout<<"\n\n\t\tSCHOOL : Jawahar Lal Nehru School ";
getch();
}
//**********************************************************
// END OF PROJECT
//**********************************************************
OUTPUT
SNAPSHOTS
DISPLAY OF “WELCOME SCREEN”:-