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
Asked Feb 2, 2020
20 views

I need help with this python programming question.

12. Stock Transaction Program
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.
help_outline

Image Transcriptionclose

12. Stock Transaction Program 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.

fullscreen
• 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 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 his
broker (both times). If this amount is positive, then Joe made a profit. If the amount is
negative, then Joe lost money.
help_outline

Image Transcriptionclose

• 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 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 his broker (both times). If this amount is positive, then Joe made a profit. If the amount is negative, then Joe lost money.

fullscreen
check_circle

Expert Answer

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:
    print("Joe made a profit")
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

Check out a sample Q&A here.

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

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: What is the Big-Oh Runtime (in terms of n) for the following segment of code?   int i; int used[n]; ...

A: Generally, we define the complexity of any code by using Big O- Notation. The complexity depends upo...

question_answer

Q: Express 384 in IEEE 32-bit floating-point format.

A: Representing 384 in IEEE 32-bit floating-point format:Step 1: Convert the given number “384” to its ...

question_answer

Q: What is the Internet?

A: The Internet is a worldwide network of trillions of computers and other tools for online use. With t...

question_answer

Q: Draw the logic diagram for the following Boolean expressions. The diagram should correspond exactly ...

A: a)Logic diagram for the given Boolean expression is,

question_answer

Q: I have having some confusion as to what exactly the defintion of  "special operator in the condition...

A: The Definition of “Special Operator in The Conditional Expression” is:In the question a query based ...

question_answer

Q: Module/Week 8 ASSIGNMENTImagine you are using a two-dimensional array as the basis for creating the ...

A: Program Instructions:Initialize a 2D char array named board and open file named board.dat.Input the ...

question_answer

Q: Given two processes in the READY state, one that is CPU-bound and one that is I/O- bound, which proc...

A: Process having high priority for running nextThe Input/output bound process should be given a high p...

question_answer

Q: What is an example of a query that is based on the tables (attached)  and includes both an arithmeti...

A: Query:SELECT COURSE.COURSE_TITLE, COURSE.COURSE_DESCRIPTION, COURSE.COURSE_TYPE_CODE FROM COURSE INN...

question_answer

Q: - Delete the salesman who has the highest salary among all salesmen

A: PROGRAM INSTRUCTIONS:Create two database tables ‘EMP’ and ‘DEPT’ and declare all required attributes...