Hi Experts, will need your help with this questions, explanations and defining each function to make it neat. Thanks! I

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

Hi Experts, will need your help with this questions, explanations and defining each function to make it neat. Thanks! I

Post by answerhappygod »

Hi Experts, will need your help with this questions, explanations and defining each function to make it neat. Thanks! I know there's same question on here but I would want another ways to do it, if possible. :)
Hi Experts Will Need Your Help With This Questions Explanations And Defining Each Function To Make It Neat Thanks I 1
Hi Experts Will Need Your Help With This Questions Explanations And Defining Each Function To Make It Neat Thanks I 1 (173.64 KiB) Viewed 28 times
Here's the csv information. Thanks!!
Hi Experts Will Need Your Help With This Questions Explanations And Defining Each Function To Make It Neat Thanks I 2
Hi Experts Will Need Your Help With This Questions Explanations And Defining Each Function To Make It Neat Thanks I 2 (7.75 KiB) Viewed 28 times
A share is the single smallest denominations of a company's stock. For example: Assuming you own shares of 2 companies, below is your current stock holding. You own 3000 shares of DBS's stock and 5000 shares of SIA's stock. 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 understand 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 being 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 default method) 1. Use a deque data structure to store the stock holding. 2. Use a list data structure to hold the stock data. 3. Read the stock data from a text file named stock portfolio.csv. 4. Append the stock data into the list and push the list into the deque. 5. Print the current holding of stock (content of the deque). 6. Prompt user to enter a stock to sell. 7. Calculate the profit/loss using the FIFO protocol. 8. Print the profit/loss. 9. Print the updated stock holding.
After successfully reading in the data, your program should print the following and prompt user to enter the stock he wants to sell. Note that 3000 units of DBS stock purchased at 22.360 was the oldest stock while Singtel 2000 units at 2.560 was the latest purchase. In a FIFO protocol, you should sell the oldest stock first. What stock do you want to sell? Sample run #1 Selling 9000 units of DBS stock at $24.89 A is the oldest purchased and C is the most recent purchased. In FIFO protocol, shares from ' A ' should be sold first, followed by shares in ' B ', then shares in ' C '
price difference is the difference between the selling and buying price. Sample run #2 Selling of a non holding stock What stock do you want to sell? OUB, 1000, 23.9 You do not hold any OUB stock
Sample run #3 Selling of a stock more than the holding number of units What stock do you want to sell? SIA, 9000,3.67 your holding of SIA is less than the number of units you want to sell. We will sell all your holdi ng (8000) units for you.
\begin{tabular}{|l|r|r|} \hline DBS & 3000 & 22.36 \\ \hline SIA & 5000 & 4.23 \\ \hline DBS & 5000 & 25.23 \\ \hline Singtel & 4000 & 3.18 \\ \hline DBS & 3000 & 23.23 \\ \hline Singtel & 1000 & 2.78 \\ \hline SIA & 3000 & 5.23 \\ \hline Singtel & 2000 & 2.56 \\ \hline \end{tabular}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply