In this project, we w make up a banking system. You are an employee of MadeUp Ba
ID: 3857838 • Letter: I
Question
In this project, we w make up a banking system. You are an employee of MadeUp Banking. Your job is to manage multiple bank accounts. Here, you would create new accounts, deposit to an account, withdraw from an account, delete account, sort the accounts, or do inspection on one or all bank accounts. In order to do this job, you would need the tool for each of those items. The bank maintains a list of accounts. This list has to be available as long as the bank is in business. Write a program in C++ to run the MadeUp Banking business. As state above, the list of account has to be available as long as you run the program. This means the list of the account has to be initialized in the main() function. Write a function for each of the items above. You will call these functions to perform any task on the bank accounts. Each account will have account number, name (last, first), and balance. The header file, function file, and main file are as the sample below. All functions are of MO e void. You will fill in the necessary function parameters In order to do this project, you would need to understand pointers, functions, and vectors among other basic C++ knowledge. You will follow the exact requirement and format of the program. Any unnecessary changes will result in points taken off.Explanation / Answer
#include<iostream>
#include<fstream>
#include<cctype>
#include<iomainp>
using namespace std; // Header files
class account{
int acno;
char name[50];
int deposit;
char type;
public:
void create_account(); //function to get data from the user
void show_account() const; //function to show data on screen
void modify(); //function to add new data
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() const; //function to show data in tabular format
int retacno() const; //function to return account number
int retdeposit() const; //function to return balance amount
int rettype() const; //function to return type of amount
};
void account::create_account(){
cout<<" Enter the account no. : ";
cin>>acno;
cout<<" Enter the name of the Account Holder: ";
cin.ignore();
cin.getline(name,50);
cout<<" Enter type of the account (C/S): ";
cin>>type;
type=toupper(type);
cout<<" Enter the Initial amount(>=500 for savings and >=1000 for current) : ";
cin>>deposit;
cout<<" Account created.....";
}
void account::show_account() const{
cout<<" Account No. :"<<acno;
cout<<" Account Holder Name: ";
cout<<name;
cout<<" Type of Account: "<<type;
cout<<" Balance amount: "<<deposit;
}
void account::modify(){
cout<<" Account no. :"<<acno;
cout<<" Modify Account Holder Name : ";
cin.ignore();
cin.getline(name,50);
cout<<" Modify Type of Account : ";
cin>>type;
type=toupper(type);
cout<<" Modify Balance amount : ";
cin>>deposit;
}
void account::dep(int x)
{
deposit+=x;
}
void account::draw(int x)
{
deposit-=x;
}
void account::report() const
{
cout<<acno<<setw(10)<<" "<<name<<setw(10)<<" "<<type<<setw(6)<<deposit<<endl;
}
int account::retacno() const
{
return acno;
}
int account::redeposit() const
{
return deposit;
}
char account::rettype() const
{
return type;
}
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 deposit/withdraw amount for given amount
void intro(); //introductory screen function
int main()
{
char ch;
int num;
intro();
do{
system("cls");
cout<<" MAIN MENU";
cout<<" 1. NEW ACCOUNT";
cout<<" 2. DEPOSIT AMOUNT";
cout<<" 3. WITHDRAW AMOUNT";
cout<<" 4. BALANCE ENQUIRY";
cout<<" 5. ALL ACCOUNT HOLDER LIST";
cout<<" 6. CLOSE AN ACCOUNT";
cout<<" 7. MODIFY AN ACCOUNT";
cout<<" 8. EXIT";
cout<<" Select your option(1-8) ";
cin>>ch;
system("cls");
switch(ch)
{
case '1' :
write_account();
break;
case '2' :
cout<<" Enter the Account No. : ";
cin>>num;
deposit_withdraw(num,1);
break;
case '3' :
cout<< Enter the Account No. : ";
cin>>num;
deposit_withdraw(num,2);
break;
case '4' :
cout<<" Enter the account no. : ";
cin>>num;
display_sp(num);
break;
case '5' :
display_all();
break;
case '6' :
cout<<" Enter the account no. :";
cin>>num;
delete_account(num);
break;
case '7' :
cout<<" Enter the Account No. : ";
cin>>num;
modify_account(num);
break;
case '8' :
cout<<" Thanks for using Banking System ";
break;
default : cout<<"";
}
cin.ignore();
cin.get();
}while(ch!='8');
return 0;
}
void write_account()
{
account ac;
ofstream outFile;
outFile.open("account.dat",ios::binary|ios::app);
ac.create_account();
outFile.write(reinterpret_cast<char *> (&ac), sizeof(account));
}
// function to read specific record from file
void display_sp(int n)
{
account ac;
bool flag=false;
ifstream inFile;
inFile.open("account.dat",ios::binary);
if(!inFile)
{
cout<<"File could not be open !! press any key.....";
return;
}
cout<<" BALANCE DETAILS ";
while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
{
if(ac.retacno()==n)
{
ac.show_account();
flag=true;
}
inFile.close();
if(flag==false)
cout<<" Account number does not exist";
}
void modify_account(int n)
{
bool found = false;
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.eof() && found==false)
{
File.read(reinterpret_cast<char *> (&ac), size of(account));
if(ac.retacno()==n)
{
ac.show_account();
cout<<" Enter the new details of account"<<endl;
ac.modify();
int pos=(-1)*static_cast<int>(sizeof(account));
File.seekp(pos,ios::cur);
File.write(reinterpret_cast<char *> (&ac), sizeof(account));
cout<<" Record Updated ";
found=true;
}
}
File.close();
if(found==false)
cout<<" 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 open !! press any key....";
return;
}
outFile.open("Temp.dat", ios::binary);
inFile.seekg(0,ios::beg);
while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
{
if(ac.retacno() != n)
{
outFile.write(reinterpret_cast<char *> (&ac), sizeof(account));
}
}
inFile.close();
outFile.close();
remove("account.dat");
rename("Temp.dat","account.dat");
cout<<" Record Deleted....";
}
void display_all()
{
account ac;
ifstream inFile;
inFile.open("account.dat", ios::binary);
if(!inFile)
{
cout<<"File could not be open!! press any keyy......";
return;
}
cout<<" Account Holder list ";
cout<<"===================================== ";
cout<<A/c no. Name Type Balance ";
cout<<"===================================== ";
while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
{
ac.report();
}
inFile.close();
}
void deposit_withdraw(int n, int option)
{
int amt;
bool found=false;
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.eof() && found==false)
{
File.read(reinterpret_cast<char *> (&ac), sizeof(account));
if(ac.retacno()==n)
{
ac.show_account();
if(option==1)
{
cout<<"to deposit amount";
cout<<"enter the amount to be deposited";
cin>>amt;
ac.dep(amt);
}
if(option==2)
{
cout<<"to withdraw amount";
cout<<"Enter the amount to be withdraw";
cin>>amt;
int bal=ac.retdeposit()-amt;
if(bal<500 && ac.rettype()=='S' || (bal<1000 && ac.rettype()=='C'))
cout<<"Insufficient balance";
else
ac.draw(amt);
}
int pos = (-1)*static_cast<int>(sizeof(ac));
File.seekp(pos,ios::cur);
File.write(reinterpret_cast<char *> (&ac), sizeof(account));
cout<<" Record Updated";
found = true;
}
}
File.close();
if(found==false)
cout<<" Record Not Found";
void intro()
{
cout<<" BANK";
cout<<" MANAGEMENT";
cout<<" SYSTEM";
cout<<" MADE BY: your name";
cout<<" SCHOOL: your school name";
cin.get();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.