Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CSE110 Principles of Programming Assignment 03.100 pts in the account, then there is a potential per share value that is equal to the price difference:
CSE110 Principles of Programming Assignment 03.100 pts in the account, then there is a potential per share value that is equal to the price difference: per Share BuyValue = purchase Price - market Price Assuming that we have the available funds to buy enough shares (and pay the $10 transaction fee), we should buy if the total value of the shares is greater than the $10 transaction fee. The total value of the shares is the per-share value times the number of shares we can afford to buy: totalBuyValue = perShare BuyValue numberOfSharesToBuy CSE110 Principles of Programming Assignment 03. 1D pts Test #3 Given Inputs Current Shares 15 Purchase Price 12 Market Price 1 Available Funds : 12 Expected Output Buy 2 shares Rationale: After paying the $10 transaction fee, there are enough funds remaining to buy 2 shares. At a purchase price vs. market price difference of $11 per share, our 2 shares represent a value gain af $22 dollars, which is $12 more than the $10 transaction fee - so we come out $12 ahead. In order for a sale (sell) to be considered profitable, the current market price (per share must be higher than the purchase price (per share) paid for current stock in the account. Additionally, the value gained by selling the shares must also cover the $10 transaction fee. In other words, if the current market price (per sharel is higher than the purchase price (per share) paid for current stock in the account, then there is a potential per share value that is equal to the price difference: perShareSellValue = marketPrice - purchase Price In this case, we should see if we have enough shares of this stock so that the total value of the shares is greater than the $10 transaction fee. The total value of the shares is the per-share value times the number of shares we currently have: totalSellValue = perShareSellValue currentShares Test #4 Given Inputs Current Shares : 1 Purchase Price : 1 Market Price 11 Available Funds : 3 Expected Outout Hold shares Rationale: Selling our 1 share for $11 will leave us with just $1 after we pay the $10 transaction fee. That is the same as what we paid for it, and we won't make any profit - so we should hold. if neither a buy nor a sell would be profitable, then we should simply hold the existing shares. Test Data Test #1 Given Inputs Current Shares : 18 Purchase Price 193 Market Price 1 Available Funds : 18 Expected Output Hold shares Rationale: Even though the current market price is very low (compared to the purchase price, after paying the $10 transaction fee, we would not have any funds left to buy shares, so we can only hold. Test #5 Given Inputs Current Shares 10 Purchase Price : 1 Market Price 3 Available Funds 39 Expected Outout Sell 10 shares Rationale: With a market price vs. purchase price vs, difference of $2 per share, we stand to make $20 from the sale of our 10 shares. This is $10 more than the price of the transaction fee, so we will come out $10 ahead - therefore we should sell all 10 shares Test #2 Given Inputs Current Shares : 20 Purchase Price : 2 Market Price : 1 Available Funds : 21 Expected Output Buy 11 shares Rationale: After paying the $10 transaction fee, there are enough funds remaining to buy 11 shares. Ata purchase price vs. market price difference of $1 per share, our 11 shares represent a value gain of $11 dollars, which is $1 more than the $10 transaction fee - so we cane out $1 ahead. Test M6 Given Inputs Current Shares : 1 Purchase Price : 1 Market Price 12 Available Funds : 8 Expected Output Sell 1 shares Rationale: Our 1 share is worth $11 more than we paid for it at the current market price. The $11 dollars obtained by selling that share now will still leave us with a profit of $1 after paying the $10 transaction fee. Profit is profit, so we should sell. Javalanguage
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started