You are on page 1of 7

#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
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<<"\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 Initial amount(>=500 for Saving and >=1000
for current ) : ";
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()

cin>>deposit. } void account::report() { cout<<acno<<setw(10)<<" "<<name<<setw(10)<<" "<<type<<setw(6)<<deposit<<endl. //function to display all account details void deposit_withdraw(int. cin>>type. } //*************************************************************** // function declaration //**************************************************************** void write_account(). int). type=toupper(type). cout<<"\n\nEnter The Name of The account Holder : ". //function to write record in binary file void display_sp(int). //introductory screen function . void account::dep(int x) { deposit+=x. gets(name). } void account::draw(int x) { deposit-=x."<<acno. cout<<"\nEnter Type of The account (C/S) : ". //function to delete record of file void display_all(). } char account::rettype() { return type.{ } cout<<"\nThe account No. } int account::retacno() { return acno. //function to modify record of file void delete_account(int). // function to desposit/withdraw amount for given account void intro(). cout<<"\nEnter The amount : ". //function to display account details given by user void modify_account(int). } int account::retdeposit() { return deposit.

EXIT". break. break. delete_account(num). case '8': cout<<"\n\n\tThanks for using bank system". : ". MODIFY AN ACCOUNT". case '5': display_all(). clrscr(). break. cout<<"\n\n\t05. cout<<"\n\n\t04.//*************************************************************** // THE MAIN FUNCTION OF PROGRAM //**************************************************************** int main() { char ch. intro(). clrscr(). cout<<"\n\n\t06. modify_account(num). cout<<"\n\n\t08. : ". 1). case '4': cout<<"\n\n\tEnter The account No. ALL ACCOUNT HOLDER LIST". cin>>ch. int num. cout<<"\n\n\n\tMAIN MENU". cout<<"\n\n\t03. WITHDRAW AMOUNT". cin>>num. break. managemnt . CLOSE AN ACCOUNT". cout<<"\n\n\t02. break. 2). do { clrscr(). cin>>num. break. cout<<"\n\n\tSelect Your Option (1-8) ". cout<<"\n\n\t07. case '3': cout<<"\n\n\tEnter The account No. : ". case '6': cout<<"\n\n\tEnter The account No. cin>>num. cin>>num. display_sp(num). break. switch(ch) { case '1': write_account(). : ". cin>>num. BALANCE ENQUIRY". case '2': cout<<"\n\n\tEnter The account No. cout<<"\n\n\t01. DEPOSIT AMOUNT". : ". case '7': cout<<"\n\n\tEnter The account No. NEW ACCOUNT". deposit_withdraw(num. deposit_withdraw(num.

outFile. int flag=0.close(). } //*************************************************************** // function to write in file //**************************************************************** void write_account() { account ac.. } cout<<"\nBALANCE DETAILS\n".close()..open("account. ofstream outFile. }while(ch!='8'). if(flag==0) cout<<"\n\nAccount number does not exist".break. ac.write((char *) &ac. sizeof(account)). } } inFile. ifstream inFile.ios::binary). return 0. outFile. return. } //*************************************************************** // function to read specific record from file //**************************************************************** void display_sp(int n) { account ac.ios::binary|ios::app). while(inFile.retacno()==n) { ac. } getch(). default :cout<<"\a".show_account().create_account(). inFile. if(!inFile) { cout<<"File could not be open !! Press any Key. outFile. sizeof(account))) { if(ac.dat".".open("account.read((char *) &ac. } //*************************************************************** // function to modify record of file //**************************************************************** .dat". flag=1.

retacno()==n) { ac. } } File.close(). ac.ios::cur).open("account.open("account.modify().ios::binary|ios::in|ios::out).. sizeof(account)). return. cout<<"\n\n\t Record Updated". account ac.read((char *) &ac. sizeof(account)). } while(File. File.close().dat".ios::binary).write((char *) &ac. int pos=(-1)*sizeof(account).ios::beg). cout<<"\n\nEnter The New Details of account"<<endl. inFile. if(!File) { cout<<"File could not be open !! Press any Key. while(inFile.read((char *) &ac. if(!inFile) { cout<<"File could not be open !! Press any Key. } //*************************************************************** // function to delete record of file //**************************************************************** void delete_account(int n) { account ac.ios::binary). if(found==0) cout<<"\n\n Record Not Found "..retacno()!=n) { outFile. return. inFile.seekg(0. ofstream outFile.write((char *) &ac. found=1. fstream File.open("Temp.show_account().. File. sizeof(account)) && found==0) { if(ac. .void modify_account(int n) { int found=0.dat". File. } outFile.dat"."..seekp(pos. sizeof(account))) { if(ac.". ifstream inFile. } } inFile.

dat".".close().dat".open("account. cout<<"\n\nEnter The amount to be deposited".show_account(). ifstream inFile. NAME Type Balance\n".dat"). if(!inFile) { cout<<"File could not be open !! Press any Key. } while(File. cout<<"\n\n\tRecord Deleted . } //*************************************************************** // function to display all accounts deposit list //**************************************************************** void display_all() { account ac. int option) { int amt.. rename("Temp..ios::binary). cout<<"====================================================\n". sizeof(account))) { ac.dat". int found=0. return.read((char *) &ac.report(). .open("account.outFile.". if(!File) { cout<<"File could not be open !! Press any Key. } cout<<"\n\n\t\tACCOUNT HOLDER LIST\n\n". fstream File. cout<<"A/c no. while(inFile. inFile. cout<<"====================================================\n".retacno()==n) { ac.close().read((char *) &ac. } //*************************************************************** // function to deposit and withdraw amounts //**************************************************************** void deposit_withdraw(int n.. } inFile. return.dat")."account.. if(option==1) { cout<<"\n\n\tTO DEPOSITE AMOUNT ".". ios::binary|ios::in|ios::out). remove("account. sizeof(account)) && found==0) { if(ac.. File. account ac.

cout<<"\n\n\t SYSTEM". withdraw".rettype()=='S') || (bal<1000 && ac. found=1. File.retdeposit()-amt.draw(amt).rettype()=='C')) cout<<"Insufficience balance". cout<<"\n\nEnter The amount to be cin>>amt.close(). cout<<"\n\nSCHOOL : your school name".write((char *) &ac. } int pos=(-1)* sizeof(ac). } //*************************************************************** // END OF PROJECT //*************************************************************** . } if(option==2) { cout<<"\n\n\tTO WITHDRAW AMOUNT ". ac. cout<<"\n\n\t Record Updated".ios::cur). } //*************************************************************** // INTRODUCTION FUNCTION //**************************************************************** void intro() { cout<<"\n\n\n\t BANK". if((bal<500 && ac. else ac.dep(amt). cout<<"\n\n\n\nMADE BY : your name". sizeof(account)). } } File. getch().cin>>amt. cout<<"\n\n\tMANAGEMENT". if(found==0) cout<<"\n\n Record Not Found ". int bal=ac.seekp(pos. File.