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

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 17:20
The liang book has an example called which is a javafx application that reads the javabook database using a preparedstatement object. using it as a guide, create a similar application called findbooks. it will read a list of authors from the bookdb created in problem 1 and display them in a listview. if the user selects an author, it should display the author's book titles in a textarea.
Answers: 2
question
Computers and Technology, 22.06.2019 16:30
Primary tech skills are skills that are necessary for success in online education
Answers: 3
question
Computers and Technology, 23.06.2019 13:30
Select the correct answer from each drop-down menu. which types of computer networks are bigger as well as smaller than a man? a man is a network of computers that covers an area bigger than a , but smaller than a .
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Afiling system in which an intermediary source of reference, such as a file card, must be consulted to locate specific files is called a(n) system. a. shelf filing b. direct filing c. indirect filing d. shingling
Answers: 1
You know the right answer?
Write a program to help a local stock trading company automate its systems. The company invests only...
Questions
question
Mathematics, 17.12.2020 20:30
question
Mathematics, 17.12.2020 20:30
question
Mathematics, 17.12.2020 20:30
question
Mathematics, 17.12.2020 20:30
question
Mathematics, 17.12.2020 20:30
question
Mathematics, 17.12.2020 20:30
Questions on the website: 13722359