”
Assignment Overview
In this assignment you will practice creating our own user-defined data structures to be used in a simple stock
market simulation. You will utilize what you have learned to date as well as using structs. It is worth 60 points
(6% of the overall grade). It is due 3/26, Monday, before midnight on Mimir.
Background
We will use some real data from the Dow Jones Industrial Average, a set of 30 stocks that are used as an indication
of the U.S. stock market.
Market
You will help create a Market struct. The proj08_market.h file provides three data members:
? string file_name , the name of the file containing the data
? vector symbol_list. A list of the short names of each of the 30 stocks in the Dow
? map stocks. The prices of the 30 stocks on the date (the key). The
prices are in order of the elements in symbol_list (that is, alphabetically by short name)
You must write the following methods:
? a constructor that takes a single string argument, a string file name
o That file contains closing stock prices for 30 stocks of the Dow Jones for a particular date (see
format below). It populates the data member stocks .
? a method double get_price(string stock, long date).
o returns the price of the stock on the date if:
the date is a valid date
the stock symbol is a valid stock symbol
o returns a -1.0 otherwise
? a method high_low_year(long year, string symbol). Returns as a pair the high and low
values (in that order) for that stock for the provided year.
o if the year or the symbol does not exist, returns the pair {-1.0, -1.0};
“
添加老师微信回复‘’官网 辅导‘’获取专业老师帮助,或点击联系老师1对1在线指导。