Question
C++ Portfolio Classes are getting to be more realistic with each programming assignment. This assignment includes the valuable aspect of inheritance to facilitate reuse of
C++
Portfolio
Classes are getting to be more realistic with each programming assignment. This assignment includes the valuable aspect of inheritance to facilitate reuse of code and operator overloading to allow the usage of familiar operators tailored specifically to the Stocks, Bonds, and Securities classes.
The objective of this assignment is to demonstrate an ability to implement inheritance and overload operators in a program.
Instructions:
You are working for a financial advisor who creates portfolios of financial securities for his clients. A portfolio is a conglomeration of various financial assets, such as stocks and bonds, that together create a balanced collection of investments.
When the financial advisor makes a purchase of securities on behalf of a client, a single transaction can include multiple shares of stock or multiple bonds.
For example:
Client-A purchases 100 shares of IBM $1 par value common stock on Jan. 20, 2020, for a total purchase price of $10,000 USD. Dividends for the year have been declared at $5 per share of common.
Client-A purchases 5 bonds is1sued by Intel Corporation with a face value of $1000 per bond and a stated interest rate of 7.5% on Jan 3, 2020, for a total purchase price of $5,000 USD. The bonds mature on Dec. 31, 2025.
It is your job to create an object-oriented application that will allow the financial advisor to maintain the portfolios for his/her clients. You will need to create several classes to maintain this information: Security, Stock, Bond, Portfolio, and Date.
The characteristics of stocks and bonds in a portfolio are shown below:
Stocks: Bonds:
Purchase date (Date) Purchase date (Date)
Purchase price (double) Purchase price (double)
Quantity purchased (int) Quantity purchased (int)
Ticker symbol (string) Issuer (string)
Par value (int) Face value (int)
Stock type (i.e. Common or Preferred) (enum) Stated interest rate (double)
Dividends per share (double) Maturity date (Date)
Several of the data members above require the use of dates. Strings will not be acceptable substitutes for date fields.
C++ does not have a built in data type for Date. Therefore, you may use this Date class in your program:
Security class (base class)
The class should contain data members that are common to both Stocks and Bonds.
Write appropriate member functions to store and retrieve information in the member variables above. Be sure to include a constructor and destructor.
Stock class and Bond class. (derived classes)
Each class should be derived from the Security class. Each should have the member variables shown above that are unique to each class.
Each class should contain a function called calcIncome that calculates the amount a client receives as dividend or interest income for each security purchase. Note that the calcIncome algorithm has been simplified for this assignment. In real life, interest is paid on most bonds semi-annually, and dividends are declared by a company once per year. In our example, we are assuming that dividends are known at the time of the stock purchase and are not subject to change. We are also assuming an annual (as opposed to semi-annual) payment of interest on bonds.
To calculate a stock puchases dividend income, use the following formula: income = dividends per share * number of shares. To calculate a bond purchases annual income, use this formula: income = number of bonds in purchase * the face value of the bonds * the stated interest rate.
In each derived class, the
The sort function. This function is part of the algorithm> library.
Write member functions to store and retrieve information in the appropriate member variables. Be sure to include a constructor and destructor in each derived class.
S should allow the user to record the purchase of some stocks and add the purchase to the Stocks list. Likewise, B should allow the user to record the purchase of some bonds and add the purchase to the Bonds list. L should list all of the securities in the portfolio, first displaying all of the Stocks, sorted by ticker symbol, followed by all of the bonds, sorted by issuer. The user should be able to add stocks, add bonds, and list repeatedly until he or she selects Q to quit.
Below are some examples of the information that needs to be entered by the user:
Prompts for the issuance of stock:
Design a Portfolio class
The portfolio has a name data member.
The class contains a vector of Stock objects and a vector of Bond objects.
There is no limit to the number of Stock and Bond puchases that can be added to a portfolio.
The Portfolio class should support operations to purchase stocks for the portfolio, purchase bonds for the portfolio, or list all of the items in the portfolio (both stocks and bonds).
Main()
You should write a main() program that creates a portfolio and presents a menu to the user that looks like this:
Prompts for the purchase of bonds:
Your Listing of Securities should look like the screenshot below. There are a couple several things to point out about the output:
- The Interest Rate for Bonds is displayed as a percentage (that is, the interest rate entered by the user must be multiplied by 100 in the output).
- The Price Per Share of Stocks is calculated based on the total purchase price of the sale divided by the number of shares purchased.
- Note that within the Stocks section, the Stocks are sorted by ticker symbol. Within the Bonds section, the bonds are sorted by issuer.
These calculations can be performed in the output statements, or separate member functions can be created for them in their respective classes.
Report Listing all Securities in the Portfolio:
#pragma once #includeStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started