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 23:00
What is one of the main problems that can occur when implementing a large number of new systems within an organization?
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
In deadlock avoidance using banker’s algorithm, what would be the consequence(s) of: (i) a process declaring its maximum need as maximum possible for each resource. in other words, if a resource a has 5 instances, then each process declares its maximum need as 5. (ii) a process declaring its minimum needs as maximum needs. for example, a process may need 2-5 instances of resource a. but it declares its maximum need as 2.
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
Jamie has to enter the names, employee id’s, and income of a group of employees into a worksheet. which option will jamie use to describe the data
Answers: 3
question
Computers and Technology, 24.06.2019 12:30
Nikki sent flyers in the mail to all houses within the city limits promoting her computer repair service what type of promotion is this and example of
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
German, 24.11.2020 22:30
question
German, 24.11.2020 22:30
Questions on the website: 13722363