0% found this document useful (0 votes)
21 views11 pages

Bank Account Management System Code

This C++ program defines a Bank_Account class to represent bank accounts. It includes functions to create, update, display, deposit to, withdraw from, and delete bank accounts. The main function provides a menu-driven interface to allow the user to perform these bank account operations by reading and writing data to a binary file called "Bank_Account.dat".

Uploaded by

Shruti Nagpal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views11 pages

Bank Account Management System Code

This C++ program defines a Bank_Account class to represent bank accounts. It includes functions to create, update, display, deposit to, withdraw from, and delete bank accounts. The main function provides a menu-driven interface to allow the user to perform these bank account operations by reading and writing data to a binary file called "Bank_Account.dat".

Uploaded by

Shruti Nagpal
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

#include<iostream>

#include<fstream>

#include<cctype>

#include<iomanip>

using namespace std;

class Bank_Account

int Money_Deposit;

char type;

int acno;

char name[70];

public:

void report() const;

int retMoney_Deposit() const;

void create_Bank_Account();

void dep(int);

int retacno() const;

void Display_Account() const;

void Updation();

char rettype() const;

void draw(int);

};

void Bank_Account::Updation()

cout<<"\n\tBank_Account No. : "<<acno;

cout<<"\n\tUpdation Bank_Account Holder Name : ";

[Link]();
[Link](name,50);

cout<<"\n\tUpdation Type of Bank_Account : ";

cin>>type;

type=toupper(type);

cout<<"\n\tUpdation Balance Total-Money : ";

cin>>Money_Deposit;

void Bank_Account::create_Bank_Account()

system("CLS");

cout<<"\n\tPlease Enter the Bank_Account No. : ";

cin>>acno;

cout<<"\n\n\tPlease Enter the Name of the Bank_Account holder : ";

[Link]();

[Link](name,50);

cout<<"\n\tPlease Enter Type of the Bank_Account (C/S) : ";

cin>>type;

type=toupper(type);

cout<<"\n\tPlease Enter The Starting Total-Money : ";

cin>>Money_Deposit;

cout<<"\n\n\tBank_Account Created..";

void Bank_Account::Display_Account() const

cout<<"\n\tBank_Account No. : "<<acno;

cout<<"\n\tBank_Account Holder Name : ";

cout<<name;

cout<<"\n\tType of Bank_Account : "<<type;

cout<<"\n\tBalance Total-Money : "<<Money_Deposit;

}
int Bank_Account::retacno() const

return acno;

char Bank_Account::rettype() const

return type;

void Bank_Account::report() const

{
cout<<acno<<setw(10)<<" "<<name<<setw(10)<<"
"<<type<<setw(6)<<Money_Deposit<<endl;

void Bank_Account::dep(int x)

Money_Deposit+=x;

void Bank_Account::draw(int x)

Money_Deposit-=x;

int Bank_Account::retMoney_Deposit() const

return Money_Deposit;

void write_Bank_Account();
void display_sp(int);

void display_all();

void delete_Bank_Account(int);

void Money_Deposit_withdraw(int, int);

void Updation_Bank_Account(int);

int main()

char ch;

int num;

do

system("CLS");

cout<<"\n\n\t\t!!!!!!!!!!!!!!!!!!!!!!!!!!!!";

cout<<"\t\tBANK MANAGEMENT SYSTEM";

cout<<"\n\t\t!!!!!!!!!!!!!!!!!!!!!!!!!!!!";

cout<<"\t\t ::MAIN MENU::\n";

cout<<"\n\t\t1. NEW Bank_Account";

cout<<"\n\t\t2. Money_Deposit Total-Money";

cout<<"\n\t\t3. WITHDRAW Total-Money";

cout<<"\n\t\t4. BALANCE ENQUIRY";

cout<<"\n\t\t5. ALL Bank_Account HOLDER LIST";

cout<<"\n\t\t6. CLOSE AN Bank_Account";

cout<<"\n\t\t7. Updation AN Bank_Account";

cout<<"\n\t\t8. EXIT";

cout<<"\n\n\t\tSelect Your Option (1-8): ";

cin>>ch;

switch(ch)
{

case '1':

write_Bank_Account();

break;

case '2':

system("CLS");

cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;

Money_Deposit_withdraw(num, 1);

break;

case '3':

system("CLS");

cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;

Money_Deposit_withdraw(num, 2);

break;

case '4':

system("CLS");

cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;

display_sp(num);

break;

case '5':

display_all();

break;

case '6':

system("CLS");

cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;

delete_Bank_Account(num);

break;

case '7':

system("CLS");

cout<<"\n\n\tPlease Enter The Bank_Account No. : "; cin>>num;

Updation_Bank_Account(num);
break;

case '8':

system("CLS");

cout<<"\n\n\tBrought To You By [Link]";

break;

default :cout<<"\a";

[Link]();

[Link]();

}while(ch!='8');

return 0;

void write_Bank_Account()

Bank_Account ac;

ofstream outFile;

[Link]("Bank_Account.dat",ios::binary|ios::app);

ac.create_Bank_Account();

[Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account));

[Link]();

void delete_Bank_Account(int n)

Bank_Account ac;

ifstream inFile;

ofstream outFile;
[Link]("Bank_Account.dat",ios::binary);

if(!inFile)

cout<<"File could not be open !! Press any Key...";

return;

[Link]("[Link]",ios::binary);

[Link](0,ios::beg);

while([Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account)))

if([Link]()!=n)

[Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account));

[Link]();

[Link]();

remove("Bank_Account.dat");

rename("[Link]","Bank_Account.dat");

cout<<"\n\nRecord Deleted ..";

void display_sp(int n)

Bank_Account ac;

bool flag=false;

ifstream inFile;

[Link]("Bank_Account.dat",ios::binary);

if(!inFile)

cout<<"File could not be open !! Press any Key...";


return;

cout<<"\n\tBALANCE DETAILS\n";

while([Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account)))

if([Link]()==n)

ac.Display_Account();

flag=true;

[Link]();

if(flag==false)

cout<<"\n\n\tBank_Account number does not exist";

void display_all()

system("CLS");

Bank_Account ac;

ifstream inFile;

[Link]("Bank_Account.dat",ios::binary);

if(!inFile)

cout<<"File could not be open !! Press any Key...";

return;

cout<<"\n\n\t\tBank_Account HOLDER LIST\n\n";

cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========\n";

cout<<"A/c no. NAME Type Balance\n";


cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!========\n";

while([Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account)))

[Link]();

[Link]();

void Updation_Bank_Account(int n)

bool found=false;

Bank_Account ac;

fstream File;

[Link]("Bank_Account.dat",ios::binary|ios::in|ios::out);

if(!File)

cout<<"File could not be open !! Press any Key...";

return;

while(![Link]() && found==false)

[Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account));

if([Link]()==n)

ac.Display_Account();

cout<<"\n\n\tPlease Enter The New Details of Bank_Account"<<endl;

[Link]();

int pos=(-1)*static_cast<int>(sizeof(Bank_Account));

[Link](pos,ios::cur); //fncallat1353

[Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account));

cout<<"\n\n\tRecord Updated";

found=true;
}

[Link]();

if(found==false)

cout<<"\n\n\tRecord Not Found ";

void Money_Deposit_withdraw(int n, int option)

int amt;

bool found=false;

Bank_Account ac;

fstream File;

[Link]("Bank_Account.dat", ios::binary|ios::in|ios::out);

if(!File)

cout<<"File could not be open !! Press any Key...";

return;

while(![Link]() && found==false)

[Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account));

if([Link]()==n)

ac.Display_Account();

if(option==1)

cout<<"\n\n\tTO Money_DepositSS Total-Money";

cout<<"\n\n\tPlease Enter The Total-Money to be


Money_Deposited: ";

cin>>amt;
[Link](amt);

if(option==2)

cout<<"\n\n\tTO WITHDRAW Total-Money";

cout<<"\n\n\tPlease Enter The Total-Money to be withdraw: ";

cin>>amt;

int bal=ac.retMoney_Deposit()-amt;

if(bal<0)

cout<<"Insufficience balance";

else

[Link](amt);

int pos=(-1)*static_cast<int>(sizeof(ac));

[Link](pos,ios::cur);//fn1353

[Link](reinterpret_cast<char *> (&ac), sizeof(Bank_Account));

cout<<"\n\n\tRecord Updated";

found=true;

[Link]();

if(found==false)

cout<<"\n\n\tRecord Not Found ";

Common questions

Powered by AI

Using binary file operations allows efficient reading and writing of structured data without needing conversion, preserving the integrity of object data types. However, it makes file content non-readable in a text editor, complicating manual edits or inspections. Binary files also require careful handling of record offsets for modifications to avoid data corruption. The lack of metadata or human-readable format can make debugging harder and non-intuitive for tracking changes in case of errors .

The 'Bank_Account' class in the program is responsible for managing various functionalities related to bank accounts. This includes creating new accounts, displaying account details, updating account information, depositing and withdrawing money, and reporting. The class encapsulates attributes like account number, holder's name, account type, and balance. It provides methods such as 'create_Bank_Account', 'Display_Account', 'Updation', 'dep' for deposit, 'draw' for withdrawal, and 'report' for reporting the account details .

The 'delete_Bank_Account' function manages data integrity by copying all records except the specified one to a temporary file, then replacing the original file with the temporary file, effectively removing the desired record. However, the function lacks confirmation prompts or backup procedures, which are important for preventing accidental deletions and ensuring data recovery. The security of the process would benefit from authentication checks to confirm the legitimacy of the deletion request .

Data inconsistency could arise if the program is interrupted between file read and write operations, possibly due to system crashes or manual termination, leading to incomplete updates. The design relies on sequential file access without record-level locking, which means concurrent accesses (if implemented) could overwrite changes if handled improperly. Additionally, the program does not check for duplicate account numbers during account creation, potentially causing conflicts with existing records .

Object-oriented programming is implemented through the encapsulation of bank account-related operations within the 'Bank_Account' class. This class defines attributes like account number, name, type, and balance as private members, and offers public methods for creating accounts, updating them, and handling transactions, which enables modularity and abstraction. The methods provide clear interfaces for interacting with account data, facilitating reusability and maintainability of the code .

Improvements to the user interface for better usability could include adding validation checks and error messages for invalid inputs, implementing confirmation dialogues for sensitive operations like deletions, and providing a more descriptive prompt for each action. Additionally, graphical user interfaces could replace text-based menus for more intuitive navigation. Enhancing accessibility by including keyboard shortcuts and more detailed instructions would also improve user experience .

During the account update process, data protection is ensured by locating the account through unique identifiers—account numbers—before making changes. The updates are performed using a temporary storage followed by an overwrite of the original file. This approach minimizes risks of data loss during updates. However, the program lacks encryption or authentication checks, which means data remains vulnerable to unauthorized access if other security measures are not implemented .

The program handles deposits by first identifying the account through user input and then asking for the deposit amount. This amount is added to the current balance using the 'dep' method. For withdrawals, the account is similarly identified, and the user is prompted to enter the withdrawal amount. The program then checks if the balance is sufficient; if not, it displays an insufficiency message. Otherwise, the amount is subtracted using the 'draw' method, and the balance is updated. Both operations utilize the 'Money_Deposit_withdraw' function to perform these tasks .

The program ensures updates to a bank account are saved to the correct record by first identifying the account using a unique account number, then reading the file sequentially until the specific record is found. It uses 'seekp()' to move the file pointer to the position of the particular record in the file, identified using the offset calculated by the size of the 'Bank_Account' object. The updated account data is then written back to this specific position in the file, effectively updating the record .

The main menu in the C++ bank management program allows for eight key user interactions: (1) creating a new bank account, (2) depositing money, (3) withdrawing money, (4) checking balance details, (5) viewing all account holders, (6) closing an account, (7) updating account details, and (8) exiting the program. Users select actions by entering the corresponding number, which triggers the associated function .

You might also like