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, 22.06.2019 13:10, LuckyCharms988
Calculating the "total price" of an item is tedious, so implement a get_item_cost method that just returns the quantity times the price for an item. by the way, the technical term for this kind of instance method is an accessor method, but you'll hear developers calling them getters because they always start with "get" and they get some value from instance attributes. in order to make the items sortable by their total total price, we need to customize our class. search the lectures slides for "magic" to see how to do this. see section 9.8 for an additional reference. the receipt class: this will be the class that defines our receipt type. obviously, a receipt will consist of the items on the receipt. this is called the composition design pattern. and it is very powerful. instance attributes: customer_name : it is very important to always know everything you can about your customers for "analytics", so you will keep track of a string customer name in objects of type receipt. date : the legal team has required that you keep track of the dates that purchases happen for "legal reasons", so you will also keep track of the string date in objects of type receipt. cart_items : this will be a list of the items in the cart and hence end up on the receipt. methods: 1. create a default constructor that can take a customer name as an argument, but if it gets no customer name, it will just put "real human" for the customer_name attribute. it should also accept a date argument, but will just use the value "today" for the date instance attribute if no date is given. the parameters should be named the same as the instance attributes to keep things simple. 2. add_item : self-descriptive. takes a parameter which we hope beyond hope is of type itemtopurchase and adds it to the cart_items. returns none. 3. print_receipt : takes a single parameter isevil, with default value true. returns a total cost of all the items on the receipt (remember to factor in the quantity). prints the receipt based on the following specification: for example, if isevil is true, and customer_name and date are the default values: welcome to evilmart, real human today have an evil day! otherwise, it should print: welcome to goodgo, real human today have an good day! then the receipt should be printed in sorted order like we discussed earlier, but whether or not it starts with the highest cost (think reverse), depends on the value of isevil. if it is evil, then the lowest cost items should print first, but if it is good, then it will print the highest cost items first. (cost meaning price*quantity). remember to return the total cost regardless! your main() function: the main flow of control of your program should go in a main() function or the program will fail all the unit tests. get the name of the customer with the prompt: enter customer name: get the date with the prompt: enter today's date then, ask the question: are you evil? your program should consider the following as true: yeah yup let's face it: yes hint: what do these strings all have in common? your program should consider all the following as false: no nah perhaps but i'm leaning no (just be glad you don't have to handle "yeah no.") okay enough horsing around. (get it? aggies? ! horsing! ) next, in the main() function, you will have to create a receipt object and start adding things into it using an input-while loop. the loop will prompt the user for the item name exactly as in the previous zylab (9.11). but unlike the previous zylab, the loop will terminate only if an empty string is entered for the item name. then, the price and the quantity will be prompted for exactly as in the previous zylab. create the itemtopurchase objects in the same manner as the previous zylab, but don't forget to add them to the receipt using your add_item instance method. then, the items on the receipt should be printed with the same formatting as in the previous zylab, of course with either "good" or "evil" ordering. however, on the last line, the total should be printed as follows: where 10 is replaced by the actual total. sample run here is what a sample run of the final program should look like: enter customer name: nate enter today's date: 12/20/2019 are you evil? bwahahahaha yes enter the item name: bottled student tears enter the item price: 2 enter the item quantity: 299 enter the item name: salt enter the item price: 2 enter the item quantity: 1 enter the item name: welcome to evilmart, nate 12/20/2019 have an evil day! salt 1 @ $2 = $2 bottled student tears 299 @ $2 = $598 total: $600
Answers: 1
image
Computers and Technology, 24.06.2019 06:30, chloeholt123
For which utilities, if any, does the landlord pay?
Answers: 2
image
Computers and Technology, 24.06.2019 08:30, ladybuggirl400
@josethesolis i need can anyone text me and follow me
Answers: 1
image
Computers and Technology, 24.06.2019 17:40, orlandokojoasem1234
Write an assembly language program to input a string from the user. your program should do these two things: 1. count and display the number of words in the user input string. 2. flip the case of each character from upper to lower or lower to upper. for example if the user types in: "hello there. how are you? " your output should be: the number of words in the input string is: 5 the output string is : hello there. how are you?
Answers: 2
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
English, 04.05.2021 14:00
Konu
Mathematics, 04.05.2021 14:00
Konu
Social Studies, 04.05.2021 14:00
Konu
Advanced Placement (AP), 04.05.2021 14:00