On your own, create a modular C++ program to calculate the gain or loss status of a stock. The data maintained for a stock object consists of the following (validation not required for this project, assume input data in valid ranges):
Trading Symbol C++ string object containing the abbreviation for the trading symbol
Company Name C++ string object containing the full name of the company
Number of Shares integral number (greater than 0 and less than or equal to 10,000 shares)
Purchase Price floating point number representing the purchase price of single stock (greater than 0 and less than or equal to 100.00)
Current Price floating point number representing the current price of single stock (greater than or equal to 0 and less than or equal to 100.00)
Define a stock class data type to contain all the private data for a single stock. Include public constructor, destructor, set, and get methods for the private data in your definition. In addition, include the following public methods in your definition:
Company Name: ABC Enterprises
Number of Shares: 563
Purchase Price (per share): 7.75
Current Price (per share): 20.25
Stock Status: GAIN Amount of Gain: 7037.50
Tax Owed: 1055.63
Create an array of these stock class objects to store the data for all stocks within a portfolio (use a named constant for the maximum number of array elements as 15). Also create an array of pointers to the stock class objects. Make each element in the array of pointers contain the address of the corresponding element in the array of stock class objects. Thus, you will have two arrays: an array of stock class objects and an array of pointers to those stock class objects.
Prompt the user for an input data file name. This data file contains the portfolios stock data where each line has one stocks data (there can be any number of lines in the fileonly read until the end of file is reached or the maximum number of array elements are read, whichever comes first):
Field Data Type Digits After Decimal Delimiter
Trading Symbol Character #
Company Name Character #
Number of Shares Numerical 0 space
Purchase Price Numerical 2 space
Current Price Numerical 2 newline
Store each line of data into an element of the array of stock class objects. After all data has been read from the file, sort the array of pointers according to increasing trading symbol. Only elements in the array of pointers should change position; elements in the array of stock class objects remain unchanged. Using the array of pointers, display the list of sorted trading symbols (3 per line, sorted order) to the user and prompt the user for trading symbol. With the user input trading symbol, search the array of stock class objects and if a match is found, display the stock information (call the DisplayData method on the stock class object). If a match cannot be found, print out an error message and exit the program
Your program should present a modular approach -- no global variables; use parameters and return values for transferring data between modules, call class methods for getting/setting/calculating/displaying data on a stock object. Your program should create and properly use (pass parameters, check return values, etc.) at least the following modules (function prototypes and descriptions are given):
a) Add a block comment at the top of the file to identify your name, file, date, class, assignment, and short description of the program.
b) Use proper alignment and spacing in your source code. Use textbook examples as a guide.
c) Compile the source code until no syntax errors are found. Run the program with a given data file and manually verify the expected and actual results. Debug as appropriate to ensure accuracy.
d) Copy and paste the generated output from the data file as a multi-line comment at the end of the source code file.
e) Attach a copy of the source code file and generated output to this sheet for full possible points as indicated above. Upload a copy of your source code file in Blackboard under the appropriate program assignment.
f) Be prepared to give a demo of your code and describe its functionality at the beginning of class on the listed due date.