Portfolio 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. 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) Security class (base class) The class should contain data members that are common to both Stocks and Bonds. 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 puchase’s dividend income, use the following formula: income = dividends per share * number of shares. To calculate a bond purchase’s 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 << operator should be overloaded to output, neatly formatted, all of the information associated with a stock or bond, including the calculated income. The < operator should also be overloaded in each derived class to enable sorting of the vectors using the sort function. This function is part of the  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. 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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Portfolio

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.

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)

Security class (base class)

The class should contain data members that are common to both Stocks and Bonds.

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 puchase’s dividend income, use the following formula: income = dividends per share * number of shares. To calculate a bond purchase’s 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 << operator should be overloaded to output, neatly formatted, all of the information associated with a stock or bond, including the calculated income.

The < operator should also be overloaded in each derived class to enable sorting of the vectors using 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.

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:

  1. 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).
  2. The Price Per Share of Stocks is calculated based on the total purchase price of the sale divided by the number of shares purchased.
  3. 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.

 

#pragma once
#include <iostream>
#include <cstdlib>
#include <cctype>
class Date{
friend std::ostream& operator«(std::ostream&, Date);
public:
Date(int d=0, int m=0, int yyyy=0) {
setDate(d, m, yyyy);
}
Date() {}
void setDate(int d, int m, int yyyy){
day = d;
month = m;
year %3D yyуу;
}
private:
int day;
int month;
int year;
};
std::ostream& operator<<(std::ostream& output, Date d){
output <« d.month <« "/" « d.day <« "/" « d.year;
return output;
}
Transcribed Image Text:#pragma once #include <iostream> #include <cstdlib> #include <cctype> class Date{ friend std::ostream& operator«(std::ostream&, Date); public: Date(int d=0, int m=0, int yyyy=0) { setDate(d, m, yyyy); } Date() {} void setDate(int d, int m, int yyyy){ day = d; month = m; year %3D yyуу; } private: int day; int month; int year; }; std::ostream& operator<<(std::ostream& output, Date d){ output <« d.month <« "/" « d.day <« "/" « d.year; return output; }
These are the STOCKS in your Client-A 401K portfolio:
Ticker symbol:
Purchase date:
Total price:
Quantity of shares:
Par Value:
Dividends per share:
Dividend Income:
GOOGL
10/15/2019
20000.00
Price per share:
Туpе:
200
100.00
10
Preferred
15.00
3000.00
Ticker symbol:
Purchase date:
Total price:
Quantity of shares:
Par Value:
Dividends per share:
Dividend Income:
IBM
1/20/2020
10000.00
Price per share:
Туре:
100
100.00
1
Common
5.00
500.00
These are the BONDS in your Client-A 401K portfolio:
Issuer:
Amazon
Purchase date:
2/1/2020
Quantity:
Total purchase price:
Stated Interest Rate:
Interest Income:
25
2500.00
Face value:
100.00
12.00
Maturity date:
1/12/2023
300.00
Issuer:
Purchase date:
Quantity:
Total purchase price:
Stated Interest Rate:
Interest Income:
Intel Corporation
1/3/2020
5000.00
Face value:
1000.00
7.50
Maturity date:
11/2/2025
375.00
Transcribed Image Text:These are the STOCKS in your Client-A 401K portfolio: Ticker symbol: Purchase date: Total price: Quantity of shares: Par Value: Dividends per share: Dividend Income: GOOGL 10/15/2019 20000.00 Price per share: Туpе: 200 100.00 10 Preferred 15.00 3000.00 Ticker symbol: Purchase date: Total price: Quantity of shares: Par Value: Dividends per share: Dividend Income: IBM 1/20/2020 10000.00 Price per share: Туре: 100 100.00 1 Common 5.00 500.00 These are the BONDS in your Client-A 401K portfolio: Issuer: Amazon Purchase date: 2/1/2020 Quantity: Total purchase price: Stated Interest Rate: Interest Income: 25 2500.00 Face value: 100.00 12.00 Maturity date: 1/12/2023 300.00 Issuer: Purchase date: Quantity: Total purchase price: Stated Interest Rate: Interest Income: Intel Corporation 1/3/2020 5000.00 Face value: 1000.00 7.50 Maturity date: 11/2/2025 375.00
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education