Our goal in this project is to create a simple banking system which allows a banker to manage different bank accounts. As a banker, you would create new accounts, deposit

Our goal in this project is to create a simple banking system which allows a banker to manage different bank accounts. As a banker, you would create new accounts, deposit to an account, withdraw from an account, transfer money from one account to another, 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.

Write a program in C++ to meet the above requirements. 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), balance and status (active/deactive). The header file, function file, and main file are as the sample below. All functions are of type 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.

Attahced is my code. It goes header file, function file, main file. I cant seem to figure out where it is failing but it wont run correctly. Any help is appriciated.

Header:

#include <iostream>
#include <vector>
#include <string>
#include <array>
#include <cstdlib>
#include <ctime>
#include <iomanip>

using namespace std;
void menu();
void makeAccount();
void printAccount();
void transfer();
void PrintAllAccounts();
void depositAccount();
void ActiveDeactive();
void withdrawAccount();
void sortAccounts(); // sort the accounts using the account numbers
void deleteAccount();

struct Account {
int AccountNumber;
string lastName;
string firstName;
double accountBalance;
bool active;
};

Function File:

void menu(int *num) {

int select = 0;
cout << “Welcome! Select options below:” << endl;
cout << “t1. Make new account.”
<< “nt2. Deposit to an account.”
<< “nt3. Withdraw from an account.”
<< “nt4. Transfer money.”
<< “nt5. Print account.”
<< “nt6. Activate/Deactivate an account.”
<< “nt7. Delete an account.”
<< “nt8. Display all accounts.”
<< “nt9. Quit.”
<< endl;

cout << “Selection:t”;

cin >> select;
*inputPtr = select;
}

void makeAccount(vector<Account>& Accounts){

Account temp;

temp.AccountNumber = rand() % 8999 + 1000;
cout << “This bank account is index number: ” << temp.AccountNumber << endl;

cout << “Last Name: ” << endl;
cin >> temp.lastName;

cout << “First Name: ” << endl;
cin >> temp.firstName;

cout << “Starting Balance :” << endl;
cin >> temp.accountBalance;

bankAccounts.push_back(temp);
}

void printAccount(vector<Account>& Accounts){
vector<Account>::iterator i;

int accountNum;
cout << “What account would you like to view? ” << endl;
cin >> accountNum;
for (i=bankAccounts.begin(); i !=bankAccounts.end() && (*i).AccountNumber != accountNum; i++){
if ((*i).AccountNumber == accountNum) {
cout << “Account Number: ” << accountNum;
cout << setw(4);
cout << “Balance: ” << (*i).accountBalance;
cout << endl;
cout << “Last Name: ” << (*i).lastName;
cout << setw(4);
cout << “First Name: ” << (*i).firstName << endl << endl;
}
else {
cout << “Invalid Account Number.” << endl;
}
}
}

void transfer(vector<Account>& Accounts){
int tempF, tempT;
int accountFrom, accountTo;
int transAmount;

vector<Account>::iterator i;
vector<Account>::iterator j;

cout << “From which account would you like to make a transfer from? Please enter account number: ” << endl;
cin >> accountFrom;
cout << endl << “From which account would you like to make a transfer to? Please enter account number: ” << endl;
cin >> accountTo;
cout << “How much would you like to transfer? :” << endl;
cin >> transAmount;

for(j = bankAccounts.begin(); j != bankAccounts.end() && (*j).AccountNumber != accountFrom; j++) {
for (i = bankAccounts.begin(); i != bankAccounts.end() && (*i).AccountNumber != accountTo; i++) {
if (accountFrom = bankAccounts[j].AccountNumber) {
tempF = bankAccounts[i].accountBalance;
bankAccounts[i].accountBalance = tempF – transAmount;
cout << “The new balance for account ” << accountFrom << “is ” << bankAccounts[i].accountBalance;
}

if (accountTo = bankAccounts[i].AccountNumber) {
tempT = bankAccounts[i].accountBalance;
bankAccounts[i].accountBalance = tempT + transAmount;
cout << “The new balance for account ” << accountTo << “is ” << bankAccounts[i].accountBalance;
}
}
}
}

void PrintAllAccounts(vector<Account>& Accounts){

vector<Account>::iterator i;

for (i=bankAccounts.begin();i!=bankAccounts.end(); i++){
cout << “Account Number: ” << bankAccounts[i].AccountNumber;
cout << setw(4);
cout << “Balance: ” << bankAccounts[i].accountBalance;
cout << endl;
cout << “Last Name: ” << bankAccounts[i].lastName;
cout << setw(4);
cout << “First Name: ” << bankAccounts[i].firstName << endl << endl;
}
}

void depositAccount(vector<Account>& Accounts) {

int deposAccount, deposAmount;

cout << “From which account would you like to make a deposit to? Please enter account number: ” << endl;
cin >> deposAccount;
cout << “How much would you like to deposit? :” << endl;
cin >> deposAmount;

vector<Account>::iterator i;

for (i=bankAccounts.begin();i!=bankAccounts.end() && (*i).AccountNumber != deposAccount; i++) {
if ((*i).AccountNumber == deposAccount) {
(*i).accountBalance += deposAmount;
cout << “The new balance for account ” << deposAccount << “is ” << (*i).AccountBalance;
}
else{
cout << “Invalid Account Number.” << endl;
}
}
}

void ActiveDeactive(vector<Account>& Accounts) {

int AcctNum;

cout << “What account would you like to activate or deactivate?” << endl;
cin >> AcctNum;

vector<Account>::iterator i;

for (i = bankAccounts.begin(); i != bankAccounts.end && (*i).AccountNumber != AcctNum; i++) {
if ((*i).AccountNumber == AcctNum) {
cout << “The current status of bank account ” << AcctNum << ” is ” << (*i).active << endl;
if ((*i).active == true) {
(*i).active == false;
} else {
(*i).active == true;
}
}
}
}

void withdrawAccount(vector<Account>& Accounts){
int withdrawAccount;
double withdrawAmount;

cout << “From which account would you like to make a withdraw from? Please enter account number: ” << endl;
cin >> withdrawAccount;
cout << “How much would you like to withdraw? :” << endl;
cin >> withdrawAmount;

vector<Account>::iterator i;

for (i=bankAccounts.begin();i!=bankAccounts.end() && (*i).AccountNumber != withdrawAccount; i++) {
if ((*i).AccountNumber == withdrawAccount) {
if (withdrawAmount <= ((*i).AccountBalance)) {
(*i).accountBalance -= withdrawAmount;
cout << “The new balance for account ” << withdrawAccount << “is ” << (*i).AccountBalance;
}
else{
cout << “Insufficient Funds”<< endl;
}
}
else {
cout << “Invalid Account Number.” << endl;
}
}
}

void sortAccounts(vector<Account>& Accounts){
vector<Account>::iterator i;

for (i = bankAccounts.begin(); i != bankAccounts.end(); i++){
sort((*i).AccountNumber);
}
}

void deleteAccount(vector<Account>& Accounts){
int delacct;

cout << “What account would you like to delete?” << endl;
cin >> delacct;

vector<account>:: iterator i;
for (i=bankAccounts.begin(); i != bankAccounts.end && (*i).AccountNumber != delacct; i++){
if ((*i).AccountNumber == delacct){
bankAccounts.erase(i);
cout << “Account ” << delacct << ” was successfully deleted” << endl;
}
else {
cout << “Invalid Account Number” << endl;
}
}
}

Main File:

#include “header_file.h”
#include “function_file.cpp”

int main(){

vector <Account> bankAccounts;

int input = 0;
int* inputPtr = &input;

menu(inputPtr);

while(input != 9) {
switch (input) {

case 1: makeAccount(bankAccounts);
break;

case 2: depositAccount(bankAccounts);
break;

case 3: withdrawAccount(bankAccounts);
break;

case 4: transfer(bankAccounts);
break;

case 5: printAccount(bankAccounts);
break;

case 6: ActiveDeactive(bankAccounts);
break;

case 7: deleteAccount(bankAccounts);
break;

case 8: PrintAllAccounts(bankAccounts);
break;

case 9: return 0;

default : cout << “Invalid choice please enter a number between 0 and 9 from the menu above” << endl;
}
menu(inputPtr);
}
return 0;
}