Is my code as efficient as possible? Why wont my average print out in decimal form?
<p>Below is my code which I have commented. Im hoping that it is in its most efficient form, if not then please advise me on how to improve it. Also my average method doesnt print out in the correct format, i want say 876543.00 but all i get is 876543 with no decimal places.</p>

<pre><code>#include "Analyser.h"
#include &lt;iomanip&gt;
#include &lt;algorithm&gt;
</code></pre>

<p>// Include Vector  m_transactions</p>

<pre><code>Analyser::Analyser(Transaction* transactions, int numTransactions)
{
// Create a Pointer which relates to a chunk of memory that is able to hold the number 
// of specified transactions. Assumption that specified numTransactions is correct.

e_Transactions = new Transaction[numTransactions];
e_numOfTransactions = numTransactions;
// Call setTransactions. Parameters passed into the constructor.
    setTransactions(transactions, numTransactions);
}

void Analyser::setTransactions(Transaction* transactions, int numTransactions)
{
    e_numOfTransactions = numTransactions;
// Access the standered library copy function to copy the transaction data from
// the primary Pointer to the empty Pointer so the data can be safely manipulated.
    std::copy(transactions, transactions + numTransactions, e_Transactions);
}


void Analyser::addTransactions(Transaction* transactions, int numTransactions)
{

// This is a temporary array which I created to hold all the transactions. 
// This must be large enough to hold the sum of all the transactions.


Transaction *tempTransactions = new Transaction[e_numOfTransactions + numTransactions];

// Move the transactions held within the temporary array and then,
// copy the added transactions onto the end.


std::move(e_Transactions, e_Transactions + e_numOfTransactions, tempTransactions);

    std::copy(transactions, transactions + numTransactions, tempTransactions + e_numOfTransactions);
// Increase the number of transactions by the required amount, for use in other methods.


e_numOfTransactions += numTransactions;

// Delete the previous e_Transactions then set e_Transactions to the tempTransactions
// for use in other methods.
delete [] e_Transactions;

e_Transactions = new Transaction[e_numOfTransactions];

std::copy(tempTransactions, tempTransactions + e_numOfTransactions, e_Transactions);

// Use the code below to slow the program down slightly when dealing with much larger sets of data.
    //delete [] tempTransactions;
}

double Analyser::averageVolume()
{
// Can't seem to print a double, appears as an int still.


double averageVolume = totalVolume() / static_cast&lt;int&gt;(e_numOfTransactions);
    return averageVolume;
}

double Analyser::averagePrice()
{
    double averagePrice = totalPrice() / static_cast&lt;int&gt;(e_numOfTransactions);
    return averagePrice;
}

int Analyser::totalVolume()
{
    int totalVolume = 0;

    for (int i = 0; i &lt; e_numOfTransactions; ++i)
    {
        totalVolume += e_Transactions[i].numShares;
    }

    return totalVolume;
}

int Analyser::totalPrice()
{
    int totalPrice = 0;

    for (int i = 0; i &lt; e_numOfTransactions; ++i)
    {
        totalPrice += (e_Transactions[i].numShares * e_Transactions[i].pricePerShare);
    }

    return totalPrice;
}

string* Analyser::topFiveStocks()
{
    string* topFiveStocks = new string[5];

// The aim is to find the number of shares brough per symbol.

// Int to hold the previous highest total shares bought for a specific stock symbol.


int pMax = INT_MAX;

// Int which repeatedly checks if the total shares has become the new highest total.


int cMax = INT_MIN;

    string previousSymbol;

// Holds the position of the transaction with stock symbol that sold the highest
// greatest number of shares.
    int symbolPos;

    for (int h = 0; h &lt; 5; ++h)
    {
        for (int f = 0; f &lt; e_numOfTransactions; ++f)
        {
            if ((e_Transactions[f].stockSymbol != previousSymbol) &amp;&amp; (numSharesBoughtOf(e_Transactions[f].stockSymbol) &gt; cMax) 
                &amp;&amp; (numSharesBoughtOf(e_Transactions[f].stockSymbol) &lt;= pMax))
            {
                cMax = numSharesBoughtOf(e_Transactions[f].stockSymbol);
                symbolPos = f;
            }
        }

        pMax = cMax;
        previousSymbol = e_Transactions[symbolPos].stockSymbol;
        cMax = INT_MIN;

        topFiveStocks[h] = previousSymbol;
    }

    return topFiveStocks;
}

string* Analyser::topFiveBuyers()
{
// Same format as the topFiveStocks() method.
    string* topFiveBuyers = new string[5];

    int pMax = INT_MAX;
    int cMax = INT_MIN;
    string previousTopBuyer;
    int symbolPos;

    for (int h = 0; h &lt; 5; ++h)
    {
        for (int f = 0; f &lt; e_numOfTransactions; ++f)
        {
            if ((e_Transactions[f].buyerName != previousTopBuyer) &amp;&amp; (numSharesBoughtBy(e_Transactions[f].buyerName) &gt; cMax) 
                &amp;&amp; (numSharesBoughtBy(e_Transactions[f].buyerName) &lt;= pMax))
            {
                cMax = numSharesBoughtBy(e_Transactions[f].buyerName);
                symbolPos = f;
            }
        }

        pMax = cMax;
        previousTopBuyer = e_Transactions[symbolPos].buyerName;
        cMax = INT_MIN;

        topFiveBuyers[h] = previousTopBuyer;
    }

    return topFiveBuyers;
}

int Analyser::numSharesBoughtOf(string&amp; stockSymbol)
{
// Create an int to hold the number of shares brought.


int ShareTotal = 0;

// Loop through the transactions and match the stock symbol to the amount of transactions
// Then return the ShareTotal variable.
    for (int i = 0; i &lt; e_numOfTransactions; ++i)
    {
        if (e_Transactions[i].stockSymbol == stockSymbol)
        {
            ShareTotal += e_Transactions[i].numShares;
        }
    }

    return ShareTotal;
}

int Analyser::numSharesBoughtBy(string&amp; buyerName)
{
// Create an int which holds the number of shares owned by a certain company.


 int companyOwnedShares = 0;

// Loop through the transactions and match the buyer name to the amount of transactions
// Then return the Buyer-Shares variable.
    for(int a = 0; a &lt; e_numOfTransactions; a++)
    {
        if(e_Transactions[a].buyerName == buyerName)
        {
            companyOwnedShares += e_Transactions[a].numShares;
        }
    }

    return companyOwnedShares;
}
</code></pre>
