Created
May 12, 2020 00:23
-
-
Save kennedysean/fcffff85bb5a08e23c64c9391a07a97c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
double DodStockPortfolio::getPortfolioValue() | |
{ | |
double returnVal = 0; | |
for (unsigned int i = 0; i < size; i++) | |
{ | |
// std::cout << &(numShares[i]) << std::endl; | |
// std::cout << &(stockValues[i]) << std::endl; | |
returnVal += (numShares[i] * stockValues[i]); | |
} | |
return returnVal; | |
} | |
double DodStockPortfolio::getPortfolioCost() | |
{ | |
double returnVal = 0; | |
for (unsigned int i = 0; i < size; i++) | |
{ | |
returnVal += (numShares[i] * stockAverageCosts[i]); | |
} | |
return returnVal; | |
} | |
double DodStockPortfolio::getTotalReturn() | |
{ | |
return (getPortfolioValue() / getPortfolioCost()) * 100 - 100.0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment