**C++ program** Mini Bank Account Management System: This system aimed to comput
ID: 3854366 • Letter: #
Question
**C++ program**
Mini Bank Account Management System: This system aimed to computerize the bank account management operations such as open an account, withdraw money, deposit money etc.
Modules: There are three main parts of the system:
1) Person, Student and Teacher objects, where Person needs to be declared as an abstract base class and Student & Teacher should be declared as derived class.
2) Bank Account containing the account holder
3) Bank transactions such as open an account, withdraw and deposit money
Main Menu: Main Menu consists of the following items:
1) Main Menu
2) Administrator Menu
3) Open Account
4) Close Account
5) Withdraw Money
6) Deposit Money
7) Display Account holder with maximum deposit
8) Exit If user choose the Administrator menu then system will display another submenu, which will show the following submenu options:
1) Create Student Record
2) Display All Student Records
3) Display All Students by Last Name
4) Display Specific Student Record
5) Modify Student Record
6) Delete Student Record
7) Create Teacher Record
8) Display All Teacher Records
9) Display Specific Teacher Record
10) Modify Teacher Record
11) Delete Teacher Record
12) Return to Main Menu
N.B: The above requirements can be considered as a guideline for this project. You can provide more functionalities for the proposed system. However, the above features must be present to achieve full credits from this Term Project. All inputs must be considered and displayed a proper error message. You can create a simple console based project with the above menu, where the system will prompt the user to enter the corresponding number from the keyboard to execute an operation. e.g. user needs to enter 3 for opening a bank account, and make sure to include exception handling, sorting.
Explanation / Answer
The program for the bank management is as follows.Here it goes:
Bank.cpp
#include<iostream.h>
#include<fstream.h>
#include<cctype.h>
#include<iomanip.h>
class acc
{
int accNo;
char accName[50];
int dep;
char accType;
public:
void newAcc();
void dispAcc() const;
void alter();
void dep(int);
void withdrawl(int);
void repo() const;
int accNo() const;
int RDepo() const;
char RType() const;
};
void acc::newAcc()
{
cout<<" Enter The acc No. :";
cin>>accNo;
cout<<" oo Enter The Name of The acc Holder : ";
cin.ignore();
cin.getline(accName,50);
cout<<" Enter Type of The acc (C/S) : ";
cin>>accType;
accType=toupper(accType);
cout<<" Enter The Initial amount(>=500 for Saving and >=1000 for current ) : ";
cin>>dep;
cout<<" oo oo Account Created..";
}
void acc::dispAcc() const
{
cout<<" Account No. : "<<accNo;
cout<<" Account Holder Name : ";
cout<<accName;
cout<<" Type of Account : "<<accType;
cout<<" Balance amount : "<<dep;
}
void acc::alter()
{
cout<<" Account No. : "<<accNo;
cout<<" Modify Account Holder Name : ";
cin.ignore();
cin.getline(accName,50);
cout<<" Modify Type of Account : ";
cin>>accType;
accType=toupper(accType);
cout<<" Modify Balance amount : ";
cin>>dep;
}
void acc::dep(int aa)
{
dep+=aa;
}
void acc::withdrawl(int aa)
{
dep-=aa;
}
void acc::repo() const
{
cout<<accNo<<setw(10)<<" "<<accName<<setw(10)<<" "<<accType<<setw(6)<<dep<<endl;
}
int acc::accNo() const
{
return accNo;
}
int acc::RDepo() const
{
return dep;
}
char acc::RType() const
{
return accType;
}
void fillAcc();
void dispSP(int);
void alterAcc(int);
void delAcc(int);
void AllDisp();
void depWith(int, int);
void orientation();
int main()
{
char choice;
int numbers;
orientation();
do
{
system("cls");
cout<<" oo oo oo MAIN MENU";
cout<<" oo oo 01. NEW ACCOUNT";
cout<<" oo oo 02. DEPOSIT AMOUNT";
cout<<" oo oo 03. WITHDRAW AMOUNT";
cout<<" oo oo 04. BALANCE ENQUIRY";
cout<<" oo oo 05. ALL ACCOUNT HOLDER LIST";
cout<<" oo oo 06. CLOSE AN ACCOUNT";
cout<<" oo oo 07. MODIFY AN ACCOUNT";
cout<<" oo oo 08. EXIT";
cout<<" oo oo Select Your Option (1-8) ";
cin>>choice;
system("cls");
switch(choice)
{
case '1':
fillAcc();
break;
case '2':
cout<<" oo oo Enter The acc No. : "; cin>>numbers;
depWith(numbers, 1);
break;
case '3':
cout<<" oo oo Enter The acc No. : "; cin>>numbers;
depWith(numbers, 2);
break;
case '4':
cout<<" oo oo Enter The acc No. : "; cin>>numbers;
dispSP(numbers);
break;
case '5':
AllDisp();
break;
case '6':
cout<<" oo oo Enter The acc No. : "; cin>>numbers;
delAcc(numbers);
break;
case '7':
cout<<" oo oo Enter The acc No. : "; cin>>numbers;
alterAcc(numbers);
break;
case '8':
cout<<" oo oo Thanks for using bank managemnt system";
break;
default :cout<<"";
}
cin.ignore();
cin.get();
}while(choice!='8');
return 0;
}
void fillAcc()
{
acc ac;
ofstream of;
of.open("acc.dat",ios::binary|ios::app);
ac.newAcc();
of.write(reinterpret_cast<char *> (&ac), sizeof(acc));
of.close();
}
void dispSP(int noo)
{
acc ac;
bool val=false;
ifstream inF;
inF.open("acc.dat",ios::binary);
if(!inF)
{
cout<<"fl could not be open !! Press any Key...";
return;
}
cout<<" BALANCE DETAILS oo";
while(inF.read(reinterpret_cast<char *> (&ac), sizeof(acc)))
{
if(ac.accNo()==noo)
{
ac.dispAcc();
val=true;
}
}
inF.close();
if(val==false)
cout<<" oo Account number does not exist";
}
//***************************************************************
// function to alter record of file
//****************************************************************
void alterAcc(int noo)
{
bool gotit=false;
acc ac;
fstream fl;
fl.open("acc.dat",ios::binary|ios::in|ios::out);
if(!fl)
{
cout<<"fl could not be open !! Press any Key...";
return;
}
while(!fl.eof() && gotit==false)
{
fl.read(reinterpret_cast<char *> (&ac), sizeof(acc));
if(ac.accNo()==noo)
{
ac.dispAcc();
cout<<" oo Enter The New Details of acc"<<endl;
ac.alter();
int position=(-1)*static_cast<int>(sizeof(acc));
fl.seekp(position,ios::cur);
fl.write(reinterpret_cast<char *> (&ac), sizeof(acc));
cout<<" oo oo Record Updated";
gotit=true;
}
}
fl.close();
if(gotit==false)
cout<<" oo oo Record Not Found ";
}
void delAcc(int noo)
{
acc ac;
ifstream inF;
ofstream of;
inF.open("acc.dat",ios::binary);
if(!inF)
{
cout<<"fl could not be open !! Press any Key...";
return;
}
of.open("Temporary.dat",ios::binary);
inF.seekg(0,ios::beg);
while(inF.read(reinterpret_cast<char *> (&ac), sizeof(acc)))
{
if(ac.accNo()!=noo)
{
of.write(reinterpret_cast<char *> (&ac), sizeof(acc));
}
}
inF.close();
of.close();
remove("acc.dat");
rename("Temporary.dat","acc.dat");
cout<<" oo oo Record Deleted ..";
}
void AllDisp()
{
acc ac;
ifstream inF;
inF.open("acc.dat",ios::binary);
if(!inF)
{
cout<<"fl could not be open !! Press any Key...";
return;
}
cout<<" oo oo ACCOUNT HOLDER LIST oo oo";
cout<<"==================================================== oo";
cout<<"A/c no. NAME Type Balance oo";
cout<<"==================================================== oo";
while(inF.read(reinterpret_cast<char *> (&ac), sizeof(acc)))
{
ac.repo();
}
inF.close();
}
void depWith(int noo, int opt)
{
int amunt;
bool gotit=false;
acc ac;
fstream fl;
fl.open("acc.dat", ios::binary|ios::in|ios::out);
if(!fl)
{
cout<<"fl could not be open !! Press any Key...";
return;
}
while(!fl.eof() && gotit==false)
{
fl.read(reinterpret_cast<char *> (&ac), sizeof(acc));
if(ac.accNo()==noo)
{
ac.dispAcc();
if(opt==1)
{
cout<<" oo oo TO DEPOSITE AMOUNT ";
cout<<" oo Enter The amount to be deposited";
cin>>amunt;
ac.dep(amunt);
}
if(opt==2)
{
cout<<" oo oo TO WITHDRAW AMOUNT ";
cout<<" oo Enter The amount to be withdraw";
cin>>amunt;
int bal=ac.RDepo()-amunt;
if((bal<500 && ac.RType()=='S') || (bal<1000 && ac.RType()=='C'))
cout<<"Insufficience balance";
else
ac.withdrawl(amunt);
}
int position=(-1)*static_cast<int>(sizeof(ac));
fl.seekp(position,ios::cur);
fl.write(reinterpret_cast<char *> (&ac), sizeof(acc));
cout<<" oo oo Record Updated";
gotit=true;
}
}
fl.close();
if(gotit==false)
cout<<" oo oo Record Not Found ";
}
void orientation()
{
cout<<" oo oo oo BANK";
cout<<" oo oo MANAGEMENT";
cout<<" oo oo SYSTEM";
cout<<" oo oo oo MADE BY : your accName";
cout<<" oo SCHOOL : your school accName";
cin.get();
}
Please rate the answer if it helps.....Thankyou
Hope it helps....
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.