With a partner, use the problem solving approach covered on day 1. Write out an
ID: 3884151 • Letter: W
Question
With a partner, use the problem solving approach covered on day 1. Write out an algorithm on paper along with hand calculations to determine expected output. Add onto the algorithm from Problem Solving Challenge 1. Kathryn bought 750 shares of Microsoft Corporation (MSFT) stock at a price of $70.43 per share. She must pay her stock broker a 2% commission for the transaction. The algorithm should calculate and display the following: 1. The number of shares and stock symbol. 2. The amount paid for the stock alone (without the commission) 3. The amount of the commission 4. The total amount paid (for the stock plus the commission) If your algorithm has numbers in it, replace them with variables or named constants so that it can be reused for other data. Example: 150 shares of Apple (AAPL) at $145.63. Calculate the profit (or loss) when the stock purchased is then sold (must pay commission again). Allow the user to be able to enter the number of shares, stock symbol, purchase price and sale price (in that order). Display all information entered, amount paid for stock, amount received from sale, commissions paid, profit (or loss), % gain (or loss) labeled and numbers all right justified in one column.Explanation / Answer
Algorithm:
Inputs:--N:number of shares,sc:per share cost,c:Commision percentage
Steps:
1.Read N.In this case N=750
2.Read per share cost,In this case sc=70.43
3.Read Commission percentage,In this case c=2%=>0.02
4.Evaluate Amount to be paid without commission=number of shares*per share cost
=750*70.43
=52822.5
5.Evaluate Commission cost=Commission percentage*number of shares*per share cost
=0.02*750*70.43
=1056.45
6.Evaluate Amount to be paid with commission=Amount to be paid without commission+Commission cost
=53878.95
7.Display N and stock symbol "$".==>750 $
8.Display Amount to be paid without commission.==>52822.5$
9.Display Commission cost==>1056.45$
10.Display Amount to be paid with commission.==>53878.95 $
11.Read number shares to be sold N'.
12.Read stock Symbol.
13.Read purchase price(cp) and sale price(sp).
14.Evaluate Commission cost=Commission percentage*number of shares N' *per share cost
=0.02* N' * 70.43
14.Evaluate Purchase Price=Commsion cost+number of shares N' *per share cost
15.Evaluate Selling Price=Commsion cost+number of shares N' *per share cost
16.Evaluate profit%=N' * 100 * (cp-sp)/cp
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.