Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A financial institution wants to develop a Java application to track its investment portfolios. Each portfolio contains 2 asset types: stocks and bonds. Each asset

A financial institution wants to develop a Java application to track its investment portfolios. Each portfolio contains 2 asset types: stocks and bonds. Each asset has specific attributes like ticker symbol, purchase price, current price, and quantity. The application needs to calculate the total value of each asset and the overall portfolio value. You are required to develop a Java application that can perform the following functions:
Define: Design Java classes for Assets, Portfolio, Stocks, and Bonds.
Create: Implement methods to create Asset objects with relevant attributes and Portfolio objects holding the references to multiple Asset types.
Update: Include methods to update the current price of an Asset and calculate its new value.
Portfolio valuation: Create methods to calculate the total value of a Portfolio considering all it's assets current price.
Please refer to the following UML diagram for reference:
Diagram 2.1 UML diagram.
Additionally, use this outline to help you solve the problem:
Classes:
Asset:
Attributes: symbol, purchasePrice, currentPrice, quantity
Methods: calculateValue(), updatePrice(newPrice), calculateReturn.
Portfolio:
Attributes: name, Asset (ArrayList of Asset Objects).
Methods: getTotalValue(), addAsset(asset), updateAssetPrice(symbol, newPrice).
Stock: (inherit from Asset)
Attributes: dividendYield
Methods: getAdditionalAttributes()(display the dividen)
Bond: (inherit from Asset)
Attributes: interestRate, maturityDate
Methods: getAdditional Attributes()(display interest rate and date).
To display the output, create a test class call main. In this class you have the following methods:
testAddAsset(): Add asset to portfolio using the method addAsset. The asset type can either be a stock asset or bond. After adding the asset, display the size of the asset arrayList and the content. Use the following values depending on the type of asset that is being added:
Stock: AAPL", 100.0,150.0,10,0.02
Bond: "US10YT",1000.0,1020.0,5,0.05
Refer to the table 2.1 below for more information:
Table 2.1: Asset type input details
\table[[\table[[Asset],[Type]],Symbol,\table[[Purchase],[Price]],\table[[Current],[Price]],Quantity,\table[[Dividend],[Yield]],\table[[Interest],[rate]],\table[[Maturity],[date]]],[Stock,AAPL,100,150,10,0.02,-,-],[Bond,US10YT,1000,1020,5,-,0.05,\table[[Current],[date]]]]
testGetTotalValue(): after adding the asset to the portfolio, use the method calculateValue() from the asset which in turn can be check with the portfolio method getTotalValue(). If the value return from the calculateValue() is the same as getTotalValue(), then it pass the test.
testUpdatePrice(): After adding the asset to the portfolio, set a new price for the asset using the updatePrice() method. Then display the value of the portfolio.
A financial institution wants to develop a Java application to track its investment portfolios. Each portfolio contains 2 asset types: stocks and bonds. Each asset has specific attributes like ticker symbol, purchase price, current price, and quantity. The application needs to calculate the total value of each asset and the overall portfolio value. You are required to develop a Java application that can perform the following functions:
Define: Design Java classes for Assets, Portfolio, Stocks, and Bonds.
Create: Implement methods to create Asset objects with relevant attributes and Portfolio objects holding the references to multiple Asset types.
Update: Include methods to update the current price of an Asset and calculate its new value.
Portfolio valuation: Create methods to calculate the total value of a Portfolio considering all it's assets current price.
Please refer to the following UML diagram for reference:
Diagram 2.1 UML diagram.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

If M is $400, P is $4, and Q is 400, then V must be

Answered: 1 week ago

Question

Verification of the identity of the employees must be made daily.

Answered: 1 week ago

Question

Adaptation to the new rules was performed easily by the employees.

Answered: 1 week ago