In: Computer Science
Starting out with Python 4th edition
Chapter 2 Programming Exercise 12 Stock Transaction Program
Not sure how to do this
CODE
purchased = 2000
buyValue = 40.0
commission = 3 / 100
sellValue = 42.75
sold = 2000
amountPaid = purchased * buyValue
purchCommission = amountPaid * commission
amountReceived = sold * sellValue
sellCommission = amountReceived * commission
amountLeft = amountReceived - sellCommission - purchCommission - amountPaid
print("Joe paid", amountPaid, "dollars for his stocks")
print("His broker was paid", purchCommission, "dollars during the purchase")
print("Joe's stocks sold for", amountReceived, "dollars")
print("The broker was paid", sellCommission, "dollars during the sale")
if amountLeft < 0:
print("Joe lost", abs(amountLeft), "dollars")
else:
print("Joe made", amountLeft, "dollars")