# 12. Stock Transaction ProgramLast month, Joe purchased some stock in Acme Software, Inc. Here are the details of thepurchase:• 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 paidfor 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 amounthe 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 for which Joe sold the stock.• 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 hisbroker (both times). If this amount is positive, then Joe made a profit. If the amount isnegative, then Joe lost money.

Question
20 views

I need help with this python programming question.

check_circle

star
star
star
star
star
1 Rating
Program –

stocks = 2000 # number of the stocks
pricePaid = 40.00 # price paid for the stock
priceSold = 42.75 # price at which stock is sold
totalPaid = stocks * pricePaid # total price paid for the stocks
totalSold = stocks * priceSold # total # price at which stocks are sold
commissionPaid = (3 * totalPaid) / 100 # commission paid when buying the stocks
moneyLeft = totalSold - commissionPaid # total money left

print("The amount of Joe paid for the stock = ", totalPaid)
print("The amount of commission Joe paid his broker when he bought the stock = ", commissionPaid)
print("The amount for which Joe sold the stock = ", totalSold)

commissionPaid = (3 * totalSold) / 100 # commission paid when selling the stocks
moneyLeft = moneyLeft - commissionPaid # money that Joe had left

print("The amount of commission Joe paid his broker when he sold the stock = ", commissionPaid)
print("The amount of money that Joe had left when he sold the stock and paid the commissions(both times) = ", moneyLeft)

# check if Joe made profit
if moneyLeft > totalPaid:
else:
print("Joe lost money")

program description –
• Number of stocks are taken in the variable
• Prices are taken in the variables – pricePaid and priceSold.
• Total paid money is stored in the variable
• Total money for selling is stored in the variable
• Commission is stored in the variable...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in