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

In this assignment you will be managing small equities portfolio made up of sing

ID: 662439 • Letter: I

Question

In this assignment you will be managing 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. Formula : (dividend rate*price) / payment cycle

Calculated Current value of equity of type float. Formula : Current*shares

Calculated value of equity after n years of type float.

Methods

Your class should have the following methods:

Public getter methods for all fields

Public Setter methods for all non computed fields

A to string method that displays the equity ticker symbol, Equity Name, Number of shares held, current price per share, Calculated current value.

A private method to calculate the current value of the equity. Current price * Number of shares held.

A private method to calculate dividend amount for each dividend payment. Dividend amount = ( current price * dividend yield) / dividend payment cycle.

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.

You should generate the following report for the portfolio.

Format : 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,87.34,4,3.35,4

D,Dominion Resources Inc,50,0,NYSE,72.41,2,3.58,4

O,Realty Income Corp.,100,2,NYSE,47.66,3.5,4.78,12

XLU,Utilities Select Sector SPDR Fund,250,1,AMEX,44.87,1.5,3.13,4

AAPL,Apple Inc,100,0,NASD,130.66,5,1.59,4

Explanation / Answer

// File: Portfolio.java
public class Portfolio
{
   // private fields
   private String tickerSymbol;
   private String equityName;
   private int numberOfSharesHeld;
   private int equityType;
   private String exchange;
   private double currentEquityPrice;
   private double estimatedYearlyPriceIncreasePercent;
   private double dividendYieldPercent;
   private double dividendPaymentCycle;
   private double dividendAmount;
   private double currentValueOfEquity;
   private double equityAfterNYears;
  
   public Portfolio()
   {
       this.tickerSymbol = "N/A";
       this.equityName = "N/A";
       this.numberOfSharesHeld = -1;
       this.equityType = -1;
       this.exchange = "";
       this.currentEquityPrice = -1;
       this.estimatedYearlyPriceIncreasePercent = -1;
       this.dividendYieldPercent = -1;
       this.dividendPaymentCycle = -1;
   }
  
   public Portfolio(String tickerSymbol, String equityName,
           int numberOfSharesHeld, int equityType, String exchange,
           double currentEquityPrice,
           double estimatedYearlyPriceIncreasePercent, double dividendYieldPercent,
           double dividendPaymentCycle)
   {
       this.tickerSymbol = tickerSymbol;
       this.equityName = equityName;
       this.numberOfSharesHeld = numberOfSharesHeld;
       this.equityType = equityType;
       this.exchange = exchange;
       this.currentEquityPrice = currentEquityPrice;
       this.estimatedYearlyPriceIncreasePercent = estimatedYearlyPriceIncreasePercent;
       this.dividendYieldPercent = dividendYieldPercent;
       this.dividendPaymentCycle = dividendPaymentCycle;
   }

   public String getTickerSymbol()
   {
       return tickerSymbol;
   }

   public String getEquityName()
   {
       return equityName;
   }

   public int getNumberOfSharesHeld()
   {
       return numberOfSharesHeld;
   }

   public int getEquityType()
   {
       return equityType;
   }

   public String getExchange()
   {
       return exchange;
   }

   public double getCurrentEquityPrice()
   {
       return currentEquityPrice;
   }

   public double getEstimatedYearlyPriceIncreasePercent()
   {
       return estimatedYearlyPriceIncreasePercent;
   }

   public double getDividendYieldPercent()
   {
       return dividendYieldPercent;
   }

   public double getDividendPaymentCycle()
   {
       return dividendPaymentCycle;
   }

   public double getDividendAmount()
   {
       return dividendAmount;
   }

   public double getCurrentValueOfEquity()
   {
       return currentValueOfEquity;
   }

   public double getEquityAfterNYears()
   {
       return equityAfterNYears;
   }

   public void setTicketSymbol(String tickerSymbol)
   {
       this.tickerSymbol = tickerSymbol;
   }

   public void setEquityName(String equityName)
   {
       this.equityName = equityName;
   }

   public void setNumberOfSharesHeld(int numberOfSharesHeld)
   {
       this.numberOfSharesHeld = numberOfSharesHeld;
   }

   public void setEquityType(int equityType)
   {
       this.equityType = equityType;
   }

   public void setExchange(String exchange)
   {
       this.exchange = exchange;
   }

   public void setCurrentEquityPrice(double currentEquityPrice)
   {
       this.currentEquityPrice = currentEquityPrice;
   }

   public void setEstimatedYearlyPriceIncreasePercent(
           double estimatedYearlyPriceIncreasePercent)
   {
       this.estimatedYearlyPriceIncreasePercent = estimatedYearlyPriceIncreasePercent;
   }

   public void setDividendPercent(double dividendYieldPercent)
   {
       this.dividendYieldPercent = dividendYieldPercent;
   }

   public void setDividendPaymentCycle(double dividendPaymentCycle)
   {
       this.dividendPaymentCycle = dividendPaymentCycle;
   }
  
   public String toString()
   {
       String result = "";
      
       result += "Equity ticker symbol       : " + getTickerSymbol() + " ";
       result += "Equity name               : " + getEquityName() + " ";
       result += "Number of shares held   : " + getNumberOfSharesHeld() + " ";
       result += "Current price per share   : " + getCurrentEquityPrice() + " ";
       result += "Calculated current value   : " + getCurrentValueOfEquity() + " ";
      
       return result;
   }
  
   private void calculateCurrentValueOfEquity()
   {
       currentValueOfEquity = getCurrentEquityPrice() * getNumberOfSharesHeld();
   }
  
   private void calculateDividendAmount()
   {
       dividendAmount = (getCurrentEquityPrice() * getDividendYieldPercent()) / getDividendPaymentCycle();
   }
  
   public void calculateEquityAfterNYears()
   {
       equityAfterNYears = getCurrentEquityPrice();
      
       for(int i = 1; i < dividendPaymentCycle; i++)
       {
           equityAfterNYears += equityAfterNYears * estimatedYearlyPriceIncreasePercent;
       }
   }
  
}

-------------------------------------------------------------------

// File: PortfolioDemo.java
public class PortfolioDemo
{
   public static void main(String[] args)
   {
       Portfolio p1 = new Portfolio("XOM", "Exon Mobil Co", 200, 0, "NYSE", 87.34, 4, 3.35, 4);
       Portfolio p2 = new Portfolio("D", "Dominion Resources Inc", 50, 0, "NYSE", 72.41, 2, 3.58, 4);
       Portfolio p3 = new Portfolio("O", "Realty Income Corp.", 100, 2, "NYSE", 47.66, 3.5, 4.78, 12);
       Portfolio p4 = new Portfolio("XLU", "Utilities Select Sector SPDR Fund", 250, 1, "AMEX", 44.87, 1.5, 3.13, 4);
       Portfolio p5 = new Portfolio("AAPL", "Apple Inc", 100, 0, "NASD", 130.66, 5, 1.59, 4);
      
       p1.calculateEquityAfterNYears();
       p2.calculateEquityAfterNYears();
       p3.calculateEquityAfterNYears();
       p4.calculateEquityAfterNYears();
      
       printPortfolio(p1);
       printPortfolio(p2);
       printPortfolio(p3);
       printPortfolio(p4);
   }
  
   public static void printPortfolio(Portfolio p)
   {
       System.out.printf("%-35s:%10s ", "Ticker symbol", p.getTickerSymbol());
       System.out.printf("%-35s:%10s ", "Equity name", p.getEquityName());
       System.out.printf("%-35s:%10d ", "Number of shares", p.getNumberOfSharesHeld());
       System.out.printf("%-35s:%10d ", "Equity type", p.getEquityType());
       System.out.printf("%-35s:%10s ", "Exchange", p.getExchange());
       System.out.printf("%-35s:%10.2f ", "Current price", p.getCurrentEquityPrice());
       System.out.printf("%-35s:%10.2f ", "Estimated yearly price increase", p.getEstimatedYearlyPriceIncreasePercent());
       System.out.printf("%-35s:%10.2f ", "Dividend yield", p.getDividendAmount());
       System.out.printf("%-35s:%10.2f ", "Dividend payment cycle", p.getDividendPaymentCycle());
       System.out.println();
   }
}