2. SHAJU
2
Submitted by
Class: XII A
Under the guidance of
PGT(Computer science)
DEPARTMENT OF COMPUTER
SCIENCE
Kendriya vidyalaya INS Dronacharya
Kochi
3. SHAJU
3
I would like to sincerely and profusely thank my
computer science teacher Mr. PGT(Computer
science) for his able guidance and vital support in
completing my project.
I would also like to extend my gratitude to our lab
assistant for providing me with all facility that was
required.
6. SHAJU
6
– for file handling, cin and
cout
– for clrscr() and getch()
functions
– for standard I/O operations
– for string handling
– for character classification
functions
–for parametric manipulation
7. SHAJU
7
This program consist of five options as follows:
To add a new account
To deposit amount
To withdraw amount
To enquire the balance amount
To view all account holder list
To close an account
To modify an account
To exit
9. SHAJU
9
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;
14. SHAJU
14
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";
}
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)
{
15. SHAJU
15
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 ";
}
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;
}
16. SHAJU
16
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<<"nntRecord Deleted ..";
}
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";
17. SHAJU
17
while(inFile.read((char *) &ac, sizeof(account)))
{
ac.report();
}
inFile.close();
}
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)
{
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
"<<endl;
cout<<"t------------------";
cout<<"nnEnter The amount to be
deposited ";