I’m writing a code that displays a Bank Statement. It involves two classes, one called Transaction and another called Statement. Transaction basically details the transaction itself (the amount, whether it is a withdrawal or deposit, and a note on what the transaction was for). Statement collects the data and compiles it together to display all the transactions that have been done and the end results (end balance, number of withdrawals/deposits, transaction history, etc).
//BankStatement.h//
#ifndef BankStatement_H
#define BankStatement_H
#include "Transaction.h"
#pragma once
#include <iostream>
#include <string>
#include <array>
#include <cstdlib> // for the library rand() function
#include <cmath>
#include <ctime>
#include <vector>
usingnamespace std;
constunsignedint TRANS_LOG_SIZE = 30;
class BankStatement
{
public:
BankStatement();
void SetBegBal(float Balance); // Validate parameter and then initialize BegBal AND EndBal
float GetBegBal();
float GetEndBal();
int GetNumEntries();
void EnterTransaction(Transaction Input); // Inserts Input transaction into next available
// slot in TransactionLog array, updates RunningBal array, and adjusts NumEntries,
// NumDeposits (or NumWithdrawals) and EndBal
void DisplayResults(); // Displays BegBal, TransactionLog array, RunningBal array, and final
// stats (i.e., EndBal, # of total transactions, # of deposits and # of withdrawls) -- see pg 37
void ArrangeTransactions(); // Arranges the Arranged array from the TransactionLog array
void PrintArranged(); // Displays the Arranged[] array
private:
array<Transaction, TRANS_LOG_SIZE > TransactionLog; // Transactions as container
array<Transaction, TRANS_LOG_SIZE > Arranged; // Sorted Transactions container
array<float, TRANS_LOG_SIZE > RunningBal; // Running balance container
float BegBal; // Balance as of last transaction entered
float EndBal; // Record of beginning balance
int NumEntries; // Total number of transactions in the statement
int NumDeposits; // Number of deposit transactions
int NumWithdrawals; // Number of withdrawal transactions
};
#endif
//main.cpp//
#include <iostream> // for cin,cout
#include <string>
#include <cmath>
#include "Transaction.h" // for processing the roll
#include "BankStatement.h" // for processing die roll
usingnamespace std;
int main() // NOTE THIS IS A NON-INTERACTIVE DRIVER!
{
BankStatement MyStatement; // Consider carefully all that takes place as a result of
// this single object declaration!
MyStatement.SetBegBal(15.92f); //Enter beginning balance
// Declare some transaction objects
Transaction T1; // TEST DATA
T1.SetAmount(123.56f);
T1.SetCode('D');
T1.SetNote("CTPay");
Transaction T2(153.86f, 'W', "Rent");
Transaction T3;
T3.SetAmount(75.56f);
T3.SetCode('D');
T3.SetNote("Tips");
Transaction T4(12.56f, 'D', "Gift");
Transaction T5;
T5.SetAmount(73.74f);
T5.SetCode('W');
T5.SetNote("Date");
Transaction T6(145.75f, 'D', "Loan");
Transaction T7;
T7.SetAmount(40.00f);
T7.SetCode('W');
T7.SetNote("Loan Payment");
Transaction T8(21.74f, 'W', "Groceries");
// Now insert the transaction objects into the bank statement
MyStatement.EnterTransaction(T1); //Enter transactions into the
MyStatement.EnterTransaction(T2); //BankStatement object
// Six more transactions entered…………………………………………………………………
MyStatement.EnterTransaction(T3);
MyStatement.EnterTransaction(T4);
MyStatement.EnterTransaction(T5);
MyStatement.EnterTransaction(T6);
MyStatement.EnterTransaction(T7);
MyStatement.EnterTransaction(T8);
//View history
MyStatement.DisplayResults();
cout << endl;
//View grouped transactions
MyStatement.ArrangeTransactions();
MyStatement.PrintArranged();
return 0;
}
However, I have got errors and taking time to figure out the issues;
Error 9 error C2040: 'Transaction::GetNote' : 'const char *(void)' differs in levels of indirection from 'std::string (void)'
Error 10 error C2065: 'MaxTransactions' : undeclared identifier
Error 12 error C2228: left of '.GetAmount' must have class/struct/union
Error 2 error C2511: 'Transaction::Transaction(float,char,char [])' : overloaded member function not found in 'Transaction'
Error 6 error C2511: 'void Transaction::SetNote(char *)' : overloaded member function not found in 'Transaction'
Error 8 error C2556: 'const char *Transaction::GetNote(void)' : overloaded function differs only by return type from 'std::string Transaction::GetNote(void)'
Error 3 error C2597: illegal reference to non-static member 'Transaction::Amount'
Error 1 error C2664: 'char *strcpy(char *,const char *)' : cannot convert argument 1 from 'std::string' to 'char *'
Error 11 error C2677: binary '[' : no global operator found which takes type 'std::array<Transaction,30>' (or there is no acceptable conversion)
The following is the example of the output from the function, DisplayResults().
The beginning balance was: $15.92
Transaction: 1 was a D amount: $123.56 for CTPay
Running Bal: $139.48
Transaction: 2 was a W amount: $153.86 for Rent
Running Bal: $-14.38 OVERDRAWN
etc., for the other transactions...................................................................... ........................................................................................................... The ending balance is: $84.01
The number of Transactions is: 8
The number of Deposits is: 4
The number of Withdrawals is: 4
The following is the result after calling the ArrangeTransactions() and PrintArranged() functions in the BankStatement class.
Printing the Deposits and Withdrawals as a group: Transaction was a D amount: $123.56 for CTPay Transaction was a D amount: $75.56 for Tips Transaction was a D amount: $12.56 for Gift

Transaction was a D amount: $145.75 for Loan Transaction was a W amount: $153.86 for Rent Transaction was a W amount: $73.74 for Date Transaction was a W amount:$40.00 for Loan Payment Transaction was a W amount: $21.74 for Groceries