Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some guidance thank you so much in advance! Assignment Requirements For this assignment you are given the following files: Assignment03.java (you must complete

image text in transcribed

image text in transcribed

I need some guidance thank you so much in advance!

Assignment Requirements For this assignment you are given the following files: Assignment03.java (you must complete this file) Problem Description and Given Info Within the main method in the Assignment03.java file, you must design and write a program to determine whether to buy, sell, or hold shares in a stock market. Your program must prompt the user to enter the 4 input values described below. It must collect the user's input and store these values in 4 different variables. It must collect the inputs in the order shown below. Your program must determine whether the user should buy, sell, or hold their shares based on the input data. It must print out an appropriate message to the user. The output must be formatted exactly like the Expected output examples shown below. Inputs 1. Current Shares - This is the number of shares of this stock currently held in the account 2. Market Price - (per share) of this stock. This is the current market price for buying or selling this stock 3. Purchase Price - (per share) paid for current stock in the account 4. Available Funds - the amount the client is willing to spend on a transaction Outputs 1. Text containing the message to either buy, sell, or hold (see examples below) Other Details Any transaction (buy or sell) costs $10. Be sure to account for this transaction fee in your profitability calculations. We cannot buy or sell if we cannot pay this $10 fee. Note that this fee can be taken out of the profit from a sell (see below). Each time we sell, it will cost us the $10 transaction fee. Each time we buy, it will cost us the $10 transaction fee, plus the cost of the shares we are buying: totalBuyCost = 10 + marketPrice numberOfSharesToBuy The number of shares we can afford to buy would be: numberOfSharesToBuy FLOOR availableFunds-transactionFee, marketPrice In order for a purchase (buy) to be considered profitable, the current market price (per share) must be lower than the purchase price (per share) paid for current stock in the account. Additionally, the amount the client is willing to spend on a purchase must allow us to buy enough shares so that the difference in value will cover the $10 transaction fee. In other words, if the current market price (per share) is lower 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: perShareBuyValue purchasePrice marketPrice = 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 perShareBuyValue numberOfSharesToBuy = 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 share) 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 purchasePrice 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 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 : 10 Market Price : 1 Purchase Price : 100 Available Funds : 10 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 #2 Given Inputs Current Shares : 20 Market Price : 1 Purchase Price : 2 Available Funds : 21 Expected Output Buy 11 shares Rationale: After paying the $10 transaction fee, there are enough funds remaining to buy 11 shares. At a 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 come out $1 ahead

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David J. Auer David M. Kroenke

13th Edition

B01366W6DS, 978-0133058352

More Books

Students also viewed these Databases questions

Question

=+free to pirate employees from competitors?

Answered: 1 week ago