Question: Write the following program in C++ (instructions and sample out is given below). You not allowed to use any class or struct. The only container
Write the following program in C++ (instructions and sample out is given below). You not allowed to use any class or struct. The only container your allowed to use is a queue and any other container is not allowed in this program:
This program should include the following main menu options:
1. Buy
2. Number of Shares Held
3. Sell
4. Total Capital Gain So Far
If option 1 (Buy) is chosen, the user should be prompted to enter how many shares they wish to buy and at what price.
These shares should be added to the queue of currently held shares
Then, prompt the user with the main menu.
If option 2 (Number of Shares Held) is chosen, the number of shares held in the queue of shares should be printed.
Then, the user should be prompted with the main menu.
If option 3 (Sell) is chosen, the user should be prompted to enter the number of shares they wish to sell and at what price.
If the number of shares to be sold exceeds the number of shares in the queue, an error message (see code below) should be printed and the program terminated.
The program should
remove these shares from the queue; and
update the capital gain/loss; and
Then, prompt the user with the main menu.
If option 4 is chosen, the total capital gain (or loss) from all transactions so far should be displayed.
Then the user should be prompted with the main menu again.
If any other entry is made, the program should print goodbye and terminate.

Follow all the instructions provided above. If any instruction is not followed or the output is incorrect, I will automatically downvote whoever answers!
When a share of common stock of some company is sold, the capital gain (or, sometimes, loss) is the difference between the share's selling price and the price originally paid to buy it. This rule is easy to under- stand for a single share, but if we sell multiple shares of stock bought over a long period of time, then we must identify the shares actually be ing sold. A standard accounting principle for identifying which shares of a stock were sold in such a case is to use a FIFO protocol-the shares sold are the ones that have been held the longest (indeed, this is the de- fault method built into several personal finance software packages). For example, suppose we buy 100 shares at $20 each on day 1, 20 shares at $24 on day 2, 200 shares at $36 on day 3, and then sell 150 shares on day 4 at $30 each. Then applying the FIFO protocol means that of the 150 shares sold, 100 were bought on day 1, 20 were bought on day 2, and 30 were bought on day 3. The capital gain in this case would therefore be 100 10+20 6+30 (6), or $940. Write a program that takes as input a sequence of transactions of the form "buy x share(s) at $y each" or "sell x share(s) at $y each," assuming that the transactions oc- cur on consecutive days and the values x and y are integers. Given this input sequence, the output should be the total capital gain (or loss) for the entire sequence, using the FIFO protocol to identify shares
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
