Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the
purchase:
- The number of shares that Joe purchased was 2,000.
- When Joe purchased the stock, he paid $40.00 per share.
- Joe paid his stockbroker a commission that amounted to 3 percent of the amount he
paid for the stock.
Two weeks later Joe sold the stock. Here are the details of the sale:
- The number of shares that Joe sold was 2,000.
- He sold the stock for $42.75 per share.
- He paid his stockbroker another commission that amounted to 3 percent of the amount
he received for the stock.
Write a program that displays the following information:
- The amount of money Joe paid for the stock.
- The amount of commission Joe paid his broker when he bought the stock.
- The amount that Joe sold the stock for.
- The amount of commission Joe paid his broker when he sold the stock.
- Display the amount of money that Joe had left when he sold the stock and paid his
broker (both times). If this amount is positive, then Joe made a profit. If the amount is
negative, then Joe lost money.

Respuesta :

Shares_Purchased = 0.0

Amt_PaidPerShare = 0.0

Commission_Percentage = 0.0

Paid_WithoutCommission = 0.0

Commission_Paid = 0.0

Total_Paid = 0.0

Shares_Sold = 0.0

Amt_SoldPerShare = 0.0

Sale_Amount = 0.0

Earned_WithoutCommission = 0.0

Commission_PaidSale = 0.0

Total_Earned = 0.0

ProfitNoProfit = 0.0

#calculation starts from here

Shares_Purchased = float(input("How many shares did you purchase? \n "

"enter in 0.0 form: "))

Amt_PaidPerShare = float(input("How much did you pay per share? \n"

"enter in 0.0 form: "))

Commission_Percentage = float(input("What percentage is your stockbroker \n"

"Charging per transaction? enter in 0.00 form: "))

Paid_WithoutCommission = Amt_PaidPerShare * Shares_Purchased

Commission_Paid = Paid_WithoutCommission * Commission_Percentage

TotalPaid = Commission_Paid + Paid_WithoutCommission

Shares_Sold = float(input("How many shares did you sell? \n "

"enter in 0.0 form: "))

Amt_SoldPerShare = float(input("How much did you sell each share for? \n"

"enter in 0.0 form: "))

Earned_WithoutCommission = Amt_SoldPerShare * Shares_Sold

Commission_PaidSale = Earned_WithoutCommission * Commission_Percentage

Total_Earned = Earned_WithoutCommission - Commission_PaidSale

ProfitNoProfit = Total_Earned - Total_Paid

#printing the output

print ("You paid the following for the shares:")

print (Paid_WithoutCommission)

print ("You paid the following in commissions to your stockbroker for the purchase:")

print (Commission_Paid)

print ("In total, you paid:")

print (Total_Paid)

print ("You sold your shares for the amount of:")

print (Earned_WithoutCommission)

print ("You paid the following in commissions to your stockbroker for the sale:")

print (Commission_PaidSale)

print ("In total, your revenue is: ")

print (Total_Earned)

if ProfitNoProfit > 0:

   print ("You have earned a profit of: %s." % ProfitNoProfit)

elif ProfitNoProfit == 0:

   print ("You have broken even")

else: print ("You have lost this amount: %s." % ProfitNoProfit)