1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GaryK [48]
3 years ago
9

You decide to buy some stocks for a certain price and then sell them at another price. Write a program that determines whether o

r not the transaction was profitable. Here are the details: • Take three separate inputs: the number of shares, the purchase price of the stocks, and the sale price, in that order. • You purchase the number of stocks determined by the input. • When you purchase the stocks, you pay the price determined by the input. • You pay your stockbroker a commission of 3 percent on the amount paid for the stocks. • Later, you sell the all of the stocks for the price determined by the input. • You pay your stockbroker another commission of 3 percent on the amount you received for the stock. Your program should calculate your net gain or loss during this transaction and print it in the following format: If your transaction was profitable (or if there was a net gain/loss of 0) print: "After the transaction, you made 300 dollars." (If, for example, you gained 300 dollars during the transaction.) If your transaction was not profitable, print: "After the transaction, you lost 300 dollars." (If, for example, you lost 300 dollars during the transaction.) Use string formatting.
Computers and Technology
1 answer:
ser-zykov [4K]3 years ago
4 0

Answer:

#here is code in python.

#read number of shares

num_share = int(input("Enter number of shares:"))

#read purchase price

buy_p = float(input("Enter purchase price:"))

#read sell price

sell_p = float(input("Enter sale price:"))

#total buying cost

buy_cost=buy_p*1.03*num_share

#total selling cost

sell_cost=sell_p*0.97*num_share

#if net profit

if(sell_cost>buy_cost):

   print("After the transaction, you made " +str(sell_cost-buy_cost)+ " dollars.")

#if net loss

else:

   print("After the transaction, you lost " +str(buy_cost-sell_cost)+ " dollars.")

Explanation:

Read the total number of shares from user.Then read buying price of a share and selling price of a share.Then calculate total buying cost including commission.Calculate total selling cost excluding the commission.If total buying cost is greater than total selling cost the print the profit else print the loss in the transaction.

Output:

Enter number of shares:10

Enter purchase price:10

Enter sale price:10

After the transaction, you lost 6.0 dollars.

You might be interested in
Why is it so important to have employees who can critically think?
kiruha [24]
Its important to have employees who can critically think because if they have to make a crucial decision for the job or project he or she is working on that best suits the situation. 
6 0
3 years ago
Read 2 more answers
____ rows and columns lets you keep headings on the screen as you work with the data in a large worksheet.
kipiarov [429]
"Freezing" rows <span>and columns lets you keep headings on the screen as you work with the data in a large worksheet.
</span><span>
The important point to consider is that you can freeze only rows at the top and columns on the left side of the worksheet and you cannot freeze in the middle of worksheet.The Freeze Panes summon isn't accessible when you're in cell altering mode (that is, you're entering an equation or information in a cell) or when a worksheet is ensured. To scratch off cell altering mode, press Enter or Esc. 
when you are going to freeze both rows and columns, you have to freeze them at the same time.</span>
3 0
3 years ago
Read 2 more answers
The value of a variable can change multiple times during the execution of a computer program.
ratelena [41]

Answer:

a. True

Explanation:

6 0
2 years ago
Float in is an example of a(n) _____. annotation, evolution, animation, simulation
Pavel [41]
Animation or C your welcome my friend
7 0
3 years ago
Which part of the computer coordinates all computer operations and performs arithmetic and logical operations on data
allochka39001 [22]

Answer:

A central processing unit (CPU) is the electronic circuitry within a computer that carries out the instructions of a computer program by performing the basic arithmetic, logical, control and input/output (I/O) operations specified by the instructions. The term has been used in the computer industry at least since the early 1960s.

5 0
3 years ago
Other questions:
  • Liam and his friend are regular viewers of their favorite podcast about photography techniques. What is the best way for them to
    15·1 answer
  • 2.7 code practice question 1 edhesive
    13·2 answers
  • Please help with the question no. 5 and 7 please help ​
    6·1 answer
  • What are Important advice to include about spyware, viruses, and other types of malware?
    8·1 answer
  • When you evaluate the use of digital media, how has it affected the newspaper business? The rise of digital media has caused new
    15·1 answer
  • Does anyone know the name of the font :) ?
    14·2 answers
  • When two well-informed people have different perspectives on a problem, it is often because they are focusing on a different app
    12·1 answer
  • Explain how mobile phone production could be more sustainable​
    8·2 answers
  • Mike logged into a shopping website and entered his username and password. Which protocol will the website use to verify his cre
    15·1 answer
  • You suspect that a bad video driver is causing a user's system to randomly crash and reboot. Where would you go to identify and
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!