The profit from the sale of a stock can be calculated as follows: Profit = ((NS

Question:

The profit from the sale of a stock can be calculated as follows: 

Profit = ((NS × SP) - SC) - ((NS × PP) + PC)

Where NS is the number of shares, PP is the purchase price per share, PC is the purchase commission paid, SP is the sale price per share, and SC is the sale commission paid. If the calculation yields a positive value, then the sale of the stock resulted in a profit. If the calculation yields a negative number, then the sale resulted in a loss.

Write a method that accepts as arguments the number of shares, the purchase price per share, the purchase commission paid, the sale price per share, and the sale commission paid. The method should return the profit (or loss) from the sale of stock. Demonstrate the method in a program that asks the user to enter the necessary data and displays the amount of the profit or loss.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Question Posted: