subject

Write a program to help a local stock trading company automate its systems. The company invests only in the stock market. At the end of each trading day, the company would like to generate and post the listing of its stocks so that investors can see how their holdings performed that day. We assume that the company invests in, say, 10 different stocks. The desired output is to produce two listings, one sorted by stock symbol and another sorted by percent gain from highest to lowest. The input data is stored in a file in the following format:
symbol openingPrice closingPrice todayHigh todayLow prevClose volume
For example, the sample data is as follows:
MSMT 112.50 115.75 116.50 111.75 113.50 6723823CBA 67.50 75.50 78.75 67.50 65.75 378233•••
The first line indicates that the stock symbol is MSMT , today’s opening price was 112.50 , the closing price was 115.75 , today’s high price was 116.50 , today’s low price was 111.75 , yesterday’s closing price was 113.50 , and the number of shares currently being held is 6723823 .
The listing sorted by stock symbols must be in the following form:
Develop this programming exercise in two steps. In the first step (part a), design and implement a stock object. In the second step (part b), design and implement an object to maintain a list of stocks.
a. (Stock Object) Design and implement the stock object. Call the class that captures the various characteristics of a stock object stockType .
The main components of a stock are the stock symbol, stock price, and number of shares. Moreover, we need to output the opening price, high price, low price, previous price, and the percent gain/loss for the day. These are also all the characteristics of a stock. Therefore, the stock object should store all this information.
Perform the following operations on each stock object:
i. Set the stock information.
ii. Print the stock information.
iii. Show the different prices.
iv. Calculate and print the percent gain/loss.
v. Show the number of shares.
a.1. The natural ordering of the stock list is by stock symbol. Overload the relational operators to compare two stock objects by their symbols.
a.2. Overload the insertion operator, ≪, for easy output.
a.3. Because data is stored in a file, overload the stream extraction operator, ≫, for easy input.
For example, suppose infile is an ifstream object and the input file was opened using the object infile . Further suppose that myStock is a stock object. Then, the statement
infile ≫ myStock;
reads data from the input file and stores it in the object myStock .
(Note that this statement reads and stores data in relevant components of myStock. )
b. Now that you have designed and implemented the class stockType to implement a stock object in a program, it is time to create a list of stock objects. Let us call the class to implement a list of stock objects stockListType . To store the list of stocks, you need to declare a vector . The component type of this vector is stockType .
Because the company also requires you to produce the list ordered by the percent gain/loss, you need to sort the stock list by this component. However, you are not to physically sort the list by the component percent gain/loss; instead, you will provide a logical ordering with respect to this component.
To do so, add a data member, a vector, to hold the indices ofthe stock list ordered by the component percent gain/loss. Call this array indexByGain. When printing the list ordered by the component percent gain/loss, use the array indexByGain to print the list. The elements of the array indexByGain will tell which component of the stock list to print next. In skeleton form, the definition ofthe class stockListType is as follows:
class stockListType {public:void insert(const stockType& item));//Function to insert a stock in the list.…private:vector indexByGain;vector list; //vector to store the list //of stocks};
c. Write a program that uses these two classes to automate the company’s analysis of stock data.

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 02:00, hctlawton
Which software would you use to create a print design? a. illustrator b. audacity c. reaper d. dreamweaver
Answers: 2
image
Computers and Technology, 23.06.2019 18:00, bubbles173883
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a. edit the sizes and other characteristics of photos that have been inserted. b. take a screenshot of an image and copy it to the clipboard for pasting. c. search for drawings or other images from a library of prepared pictures. d. make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
image
Computers and Technology, 23.06.2019 20:00, boo3972
Match the file formats with the types of multimedia they can store
Answers: 2
image
Computers and Technology, 24.06.2019 12:40, kanga06
Match the feature to the network architecture. expensive to set up useful for a small organization easy to track files has a central server inexpensive to set up difficult to track files useful for a large organization does not have a central server client- server network peer-to-peer network
Answers: 3
You know the right answer?
Write a program to help a local stock trading company automate its systems. The company invests only...

Questions in other subjects:

Konu
Health, 08.06.2021 04:50
Konu
French, 08.06.2021 05:00
Konu
Arts, 08.06.2021 05:00