Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this project, we will make up a banking system. You are an employee of MadeUp

ID: 3801461 • Letter: I

Question

In this project, we will 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 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. REFERENCE BELOW

In this project, you need the following essential functions:

menu() - this function displays all the available options that a bank clerk can perform.

The menu should be display every time for the new selection. The format as follow:

Selection:

makeAccount() - this function create the new bank account. The bank account has account number, first name, last name, and account balance. The account number is a 4-digit number. It can be generated randomly. Two bank accounts cannot have the same account number. When generating the new bank account number, make sure that it is not existed in the current list of bank accounts. The user can input first name, last name, and the starting balance. The starting balance is a double number. The format as follow:

printAllAccounts() - this function print out all the current accounts. The format as follow:

printAccount() - this function print out only one account. The function prompts for the account number from the user. If the account exists, the function print out the bank account with the format as before. If the account does not exist, the function print out the a prompt that the account does not exist.

depositAccount() - this function deposit an amount to the bank account. The function prompt the user for bank account and balance to be deposited. After the deposit, the bank account should be updated with the balance. You can use the print out function to check this. If the account does not exist, display a message that the account does not exist. The format as follow:

withdrawAccount() - this function withdraw an amount from the bank account. The function prompts the user for bank account and balance to be withdrawn. After the withdrawal, the bank account should be updated with the balance. You can use the print out function to check this. If the account does not exist, display a message that the account does not exist. The format as follow:

deleteAccount() - this function delete an account. The function prompts the user for the account number to be deleted. After deletion, the list of bank accounts should be updated. You can use the the print out function to check this. If the account does not exist, display a message that the account does not exist. The format as follow:

sortAccounts() - this function sort the bank account by the account numbers. Use this function after the makeAccount() function to sort the accounts after making new account.

validInput() - this is a general function. This function check if the user input is valid. This function only checks the input number. The number could be the account number (for printing, deposit, or withdraw an account), or amount input (starting balance, deposit, or withdraw). Write this function in a way that it can be reused for all the function that needs inputting numbers. This function should be used with makeAccount(), printAccount(), depositAccount(),withdrawAccount(), and deleteAccount() functions.Thefollowings are the few examples.

Creating new account:

Deposit to an account (1):

Deposit to an account (2):

B. Program Structure

Create a vector of the bank accounts. Each element of the vector will have all the account information. To do this, you would have to use data structure. The keyword struct in C++ will make a data structure. Inside the data structure, you will define all of the account information. The following is an example:

The code snippet above defines data structure type Account and a vector name bankAccounts of type Account. Each element of the vector will have member accountNumber, lastName, firstName, and accountBalance.

The vector should be defined in the main() function. This means that as long as the program running (the bank is operating), we have the list of bank accounts. This should not be the global variable. The program should be running until terminated by the user.

In order to update the information of bank accounts in the vector, you would have to pass by reference to the functions. Another option is pass by pointer. You can explore this option if desire. Because the data in the vector is of the special type, you have to make a template for the typename. Template allows you to write functions independent of the data type being passed to the functions. The example of a prototype function as follow:

In the code snippet above, we create a new typename typeStruct using the keyword template and typename. typeStruct is just a random typename. You can name it to some other names. This typename will now take whichever type being passed to the function. In our case, we’re passing the vector of data structure to the function. The typename will take the type Account as we defined in the main() function.

Explanation / Answer

Here is the code for Bankin.h:

#include <iostream>
#include <vector>
using namespace std;
struct Account{
int accountNumber;
string lastName;
string firstName;
double accountBalance;
}Account;

int menu();
template <typename typeStruct>
void makeAccount(vector <typeStruct>&);
template <typename typeStruct>
void printAllAccounts(vector <typeStruct>);
template <typename typeStruct>
void printAccount(vector <typeStruct>);
template <typename typeStruct>
void depositAccount(vector <typeStruct>&);
template <typename typeStruct>
void withdrawAccount(vector <typeStruct>&);
template <typename typeStruct>
void deleteAccount(vector <typeStruct>&);
template <typename typeStruct>
void sortAccounts(vector <typeStruct>&);

And the code for Banking.cpp is:

#include "Banking.h"
#include <iomanip>
int menu()
{
    int choice;
    cout << "Welcome to MadeUp Banking. Select options below:" << endl;
    cout <<" 1. Make new account." << endl;
    cout <<" 2. Display all accounts." << endl;
    cout <<" 3. Deposit to an account." << endl;
    cout <<" 4. Withdraw from an account." << endl;
    cout <<" 5. Print account." << endl;
    cout <<" 6. Delete an account." << endl;
    cout <<" 7. Quit." << endl;
    cout <<"   Selection: ";
    cin >> choice;
    while(choice < 1 || choice > 7)
    {
        cout << "Invalid choice. Enter a valid choice: ";
        cin >> choice;
    }
    return choice;
}
template <typename typeStruct>
void makeAccount(vector <typeStruct>& myVec)
{
    bool duplicate = true;
    int accNum;
    string fName, lName;
    double balance;
    while(duplicate)
    {
       duplicate = false;
       accNum = rand() % 9000 + 1000;
      for(int i = 0; i < myVec.size(); i++)
            if(myVec.get(i).accountNumber == accNum)
                duplicate = true;
        if(!duplicate)
            break;      
    }      
    cout << "Creating bank account number " << accNum;
    typeStruct account;
    account.accountNumber = accNum;
    cout << "Enter first name: ";
    cin >> fName;
    account.firstName = fName;
    cout << "Enter last name: ";
    cin >> lName;
    account.lastName = lName;
    cout << "Enter starting balance: ";
    cin >> balance;
    account.accountBalance = balance;
    myVec.push_back(account);
}
template <typename typeStruct>
void printAllAccounts(vector <typeStruct> myVec)
{
    for(int i = 0; i < myVec.size(); i++)
    {
       cout << "Account number: " << myVec.get(i).accountNumber << " ";
       cout << "Balance: " << fixed << setprecision(2) << myVec.get(i).accountBalance << endl;
       cout << "Last name: " << myVec.get(i).lastName << " " << "First name: " << myVec.get(i).firstName << endl;
    }
}
template <typename typeStruct>
void printAccount(vector <typeStruct> myVec)
{
    int accNum;
    cout << "Enter the account number: ";
    cin >> accNum;
    bool found = false;
    for(int i = 0; i < myVec.size(); i++)
    {
       if(myVec.get(i).accountNumber == accNum)
       {
          cout << "Account number: " << myVec.get(i).accountNumber << " ";
           cout << "Balance: " << fixed << setprecision(2) << myVec.get(i).accountBalance << endl;
           cout << "Last name: " << myVec.get(i).lastName << " " << "First name: " << myVec.get(i).firstName << endl;
           found = true;
           break;
       }
    }
    if(!found)
        cout << "Account number doesn't exist..." << endl;
}
template <typename typeStruct>
void depositAccount(vector <typeStruct>&myVec)
{
    int accNum;
    double amount;
    cout << "Enter the account number to deposit: ";
    cin >> accNum;
    cout << "Enter amount to be deposited: ";
    cin >> amount;
    bool found = false;
    for(int i = 0; i < myVec.size(); i++)
    {
       if(myVec.get(i).accountNumber == accNum)
       {
          myVec.get(i).accountBalance += amount;
          found = true;
          break;
       }
    }
    if(!found)
        cout << "Account number doesn't exist..." << endl;   
}
template <typename typeStruct>
void withdrawAccount(vector <typeStruct>& myVec)
{
    int accNum;
    double amount;
    cout << "Enter the account number to withdraw: ";
    cin >> accNum;
    cout << "Enter amount to be withdrawn: ";
    cin >> amount;
    bool found = false;
    for(int i = 0; i < myVec.size(); i++)
    {
       if(myVec.get(i).accountNumber == accNum)
       {
          myVec.get(i).accountBalance -= amount;
          found = true;
          break;
       }
    }
    if(!found)
        cout << "Account number doesn't exist..." << endl;   
}
template <typename typeStruct>
void deleteAccount(vector <typeStruct>& myVec)
{
    int accNum;
    double amount;
    cout << "Enter the account number to delete: ";
    cin >> accNum;
    bool found = false;
    for(int i = 0; i < myVec.size(); i++)
    {
       if(myVec.get(i).accountNumber == accNum)
       {
          myVec.erase(myVec.begin() + i);
          found = true;
          break;
       }
    }
    if(!found)
        cout << "Account number doesn't exist..." << endl;   
}
template <typename typeStruct>
void sortAccounts(vector <typeStruct>&)
{
   
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote