In this assignment you will create a c++ program to manage a small equities port
ID: 3683895 • Letter: I
Question
In this assignment you will create a c++ program to manage a small equities portfolio made up of single company stocks, Exchange traded funds (ETF), and a Real Estate Investment Trust (REIT). Each object is an equity so you should have a class that is used to instantiate an equity object. The class should have the following private fields. Ticker symbol of type string Equity Name of type string Number of shares held of type integer. Equity type of type integer (0 = stock, 1 = ETF , 2 = REIT ) The Exchange of type string (NSYE, NASDQ, etc) Current equity price of type float Estimated yearly price increase in percent float . Dividend yield in percent Dividend payment cycle of type integer. (1 = Yearly, 4 = Quarterly, 12 = Monthly). Calculated Dividend amount of type float. Calculated Current value of equity of type float. Calculated value of equity after n years of type float. Methods Your class should have the following methods. 1) Public getter methods for all fields 2) Public Setter methods for all non computed fields 3) A print out method that displays the equity ticker symbol, Equity Name, Number of shares held, current price per share, Calculated current value. 4) A private method to calculate the current value of the equity. Current price * Number of shares held. 5) A private method to calculate dividend amount for each dividend payment. Dividend amount = ( current price * dividend yield) / dividend payment cycle. 6) A method to calculate the value of your equity holding after n-years. To perform this calculation you must for each year compute a new current price based on the estimated yearly price increase for n-years. This is a recurrence relation on the price. You will also need to sum up all dividend payments for over n-years and add that to the value of the equity value after n-years. 7) You should generate the following report for the portfolio. The data you will use is in the file attached
DATA
ticker symbol,Equity name,number of shares,Equity type,Exchange,current price,Estimated yearly price increase, dividend yield, Dividend payment cycle.
XOM,Exon Mobil Co,200,0,NYSE,81.34,4,3.35,4
D,Dominion Resources Inc,50,0,NYSE,73.41,2,3.58,4
O,Realty Income Corp.,100,2,NYSE,45.66,3.5,4.78,12
XLU,Utilities Select Sector SPDR Fund,250,1,AMEX,47.87,1.5,3.13,4
AAPL,Apple Inc,100,0,NASD,112.66,5,1.59,4
Explanation / Answer
#include <iostream>
using namespace std;
class ExchangeTrade
{
public:
void setTicketSymbol( string symbol );
string getTicketSymbol( void );
void setEquintity(string eqt);
string getEquity( void );
void setExchange(string exh);
string getExchage( void );
void setShares(int shares);
int getNoOfShares(void);
void setEquityType(int type);
int getEquityTypr( void );
int getDividendYield(void);
void setDividendYield(int yield);
void setPaymentCycle(int payment);
int getPaymentCycle(void);
void setCurrentPrice(float current);
float getCurrentPrice(void);
void setEstimatedPrice(float price);
float getEstimatedPrice(void);
void print(void);
float currentValue();
float calculateDividendAmount();
float currentPriceAfterNyears(int years);
ExchangeTrade(string ticketSymbol, string equity, string exchange, int noOfShares, int equityType, int dividendYield, int dividendPaymentCycle, float currentPrice, float estimatedPrice); // This is the constructor
private:
string ticketSymbol,equity,exchange;
int noOfShares,equityType,dividendYield,dividendPaymentCycle;
float currentPrice,estimatedPrice;
};
// Member functions definitions including constructor
ExchangeTrade::ExchangeTrade(string ticketSymbol, string equity, string exchange, int noOfShares, int equityType, int dividendYield, int dividendPaymentCycle, float currentPrice, float estimatedPrice)
{
cout << "Object created" << endl;
}
void ExchangeTrade::setTicketSymbol( string symbol )
{
ticketSymbol = symbol;
}
string ExchangeTrade::getTicketSymbol( void )
{
return ticketSymbol;
}
void ExchangeTrade::setEquintity(string eqt){
equity = eqt;
}
string ExchangeTrade::getEquity( void ){
return equity;
}
void ExchangeTrade::setExchange(string exh){
exchange = exh;
}
string ExchangeTrade::getExchage( void ){
return exchange;
}
void ExchangeTrade::setShares(int shares){
noOfShares = shares;
}
int ExchangeTrade::getNoOfShares(void){
return noOfShares;
}
void ExchangeTrade::setEquityType(int type){
equityType = type;
}
int ExchangeTrade::getEquityTypr( void ){
return equityType;
}
int ExchangeTrade::getDividendYield(void){
return dividendYield;
}
void ExchangeTrade::setDividendYield(int yield){
dividendYield = yield;
}
void ExchangeTrade::setPaymentCycle(int payment){
dividendPaymentCycle = payment;
}
int ExchangeTrade::getPaymentCycle(void){
return dividendPaymentCycle;
}
void ExchangeTrade::setCurrentPrice(float current){
currentPrice = current;
}
float ExchangeTrade::getCurrentPrice(void){
return currentPrice;
}
void ExchangeTrade::setEstimatedPrice(float price){
estimatedPrice = price;
}
float ExchangeTrade::getEstimatedPrice(void){
return estimatedPrice;
}
void ExchangeTrade::print(){
cout<<"ticketSymbol: "<<ticketSymbol<<" equity: "<<equity<<" number of shares: "<<noOfShares<<" currentPrice"<<currentPrice<<" currentValue: "<<currentValue();
}
float ExchangeTrade::currentValue(){
return noOfShares * currentPrice;
}
float ExchangeTrade::calculateDividendAmount(){
return ( currentPrice * dividendYield) / dividendPaymentCycle;
}
float ExchangeTrade::currentPriceAfterNyears( int years){
float total = 0.0;
for(int i=0;i<years;i++){
total = total + calculateDividendAmount();
}
return total;
}
// Main function for the program
int main( )
{
ExchangeTrade exchangeTrade("XOM","Exon", "Mobil Co",200,0,81.34,4,3.35,4.0);
exchangeTrade.print();
return 0;
}
OUTPUT