In this assignment you will create a c++ program to manage a small equities port
ID: 3689219 • 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:
Data 1:
Ticker symbol= XOM
Equity name=Exon Mobil Co
Number of shares= 200
Equity type= 0
Exchange= NYSE
Current price=81.34
Estimated yearly price increase=4
Dividend yield= 3.35
Dividend payment cycle= 4
Data 2:
Ticker symbol= D
Equity name=Dominion Resources
Number of shares= 50
Equity type= 0
Exchange= NYSE
Current price=73.41
Estimated yearly price increase=2
Dividend yield= 3.58
Dividend payment cycle= 4
Data 3:
Ticker symbol= O
Equity name=Realty Income Corp
Number of shares= 100
Equity type= 2
Exchange= NYSE
Current price=45.66
Estimated yearly price increase=3.5
Dividend yield= 4.78
Dividend payment cycle= 12
Data 4:
Ticker symbol= XLU
Equity name=Utilities Select Sector SPDR Fund
Number of shares= 250
Equity type= 1
Exchange= AMEX
Current price=47.87
Estimated yearly price increase=1.5
Dividend yield= 3.13
Dividend payment cycle= 4
Data 5:
Ticker symbol= AAPL
Equity name=Apple Inc
Number of shares= 100
Equity type= 0
Exchange= NASD
Current price=112.66
Estimated yearly price increase=5
Dividend yield= 1.59
Dividend payment cycle= 4
The top of the report should be blank followed by a line that says Equity report followed by a report that contains the following information.
Equity ticker symbol
Equity Name Equity Type ( Stock, ETF, or REIT)
Equity Current price
Number of shares held
Current value of shares held
Estimated increase in share price per year in percent.
Estimated value of shares held in 5 years and 10 years.
At the bottom of the report should be the total current value of all shares and the total estimated 5 year and 10 year future values of all shares held.
Explanation / Answer
import java.io.*;
import java.util.Scanner;
class Records {
public String name[][] = new String[10][10];
void getdata(int n)
{
Scanner get = new Scanner(System.in);
int limit=n;
System.out.println("Enter "+limit+" records ");
for(int i=0;i<limit;i++)
{
System.out.println("Enter records as #"+(i+1)+" Tickersymbol, Equityname,NumberofShares,EquityType,Exchange,CurrentPrice,EstimatedYearlyPrice,DividendYield,DividendPaymentCycle :");
for(int j=0;j<9;j++)
{
name[i][j] = get.nextLine();
}
}
display(limit);
}
void display(int limit)
{
System.out.println("Recorded as Tickersymbol"+" "+"Equityname"+" "+"NUmberofShares"+" "+"EquityType"+" "+"Exchange"+" "+"CurrentPrice"+" "+"EstimatedYearlyPrice"+" "+"DividendYield"+" "+"DividendPaymentCycle");
for(int i=0;i<limit;i++)
{
for(int j=0;j<9;j++)
{
System.out.print(name[i][j]+" ");
}
System.out.println();
}
}
}
class TickerRecords{
public static void main(String args[]) throws IOException
{
Scanner in = new Scanner(System.in);
System.out.print("Enter Number of Records:");
int n = in.nextInt();
Records rc = new Records();
rc.getdata(n);
PrintStream output = new PrintStream(new File("Records.txt"));
output.println("Tickersymbol"+" "+"Equity name"+" "+"NUmberofShares"+" "+"EquityType"+" "+"Exchange"+" "+"CurrentPrice"+" "+"EstimatedYearlyPrice"+" "+"DividendYield"+" "+"DividendPaymentCycle");
output.println("======================================");
for(int i=0;i<n;i++)
{
for(int j=0;j<9;j++)
{
output.print(rc.name[i][j]+" ");
}
output.println();
output.println("======================================");
}
output.close();
}
}
note- by using the above code with required modifications for calculations the given question can be answered.