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
A wireframe is a sketch detailing where text and images will be placed on a website. T/F
kirill115 [55]
Your answer would be true. 
3 0
3 years ago
State three reasons why users attach speakers to their computer​
____ [38]

Answer:

For listening sake

To listen to information from the computer

They receive audio input from the computer's sound card and produce audio output in the form of sound waves.

8 0
3 years ago
How were images captured before the invention of the camera?
xeze [42]

Answer:

The British inventor Fox Talbot produced his first successful photographic images in 1834, without a camera, by placing objects onto paper brushed with light-sensitive silver chloride, which he then exposed to sunlight.

Explanation:

5 0
3 years ago
Each cable type can transport data at a particular speed only so far before its signals begin to weaken past the point that a re
Nataliya [291]

Answer:

attenuation

Explanation:

Based on the information provided within the question it can be said that the phenomenon that is being described in this scenario is known as attenuation. In the context of physics, this refers to the gradual loss of intensity of something when traveling through a medium. Which in this case would be the data signals travelling through the cables.

7 0
3 years ago
PLZZZZZZZZ HURRY What is FireWire?
ycow [4]

Answer:C

Explanation:

7 0
3 years ago
Read 2 more answers
Other questions:
  • A(n) _____ is a simple database program whose records have no relationship to one another.
    10·1 answer
  • Plugging in a cable is a good troubleshooting technique. <br> True or false
    5·1 answer
  • Temporary storage location for cutting and pasting
    9·1 answer
  • ________ to a base class may be assigned the address of a derived class object.
    8·2 answers
  • An interpreter _______. converts the procedural language one statement at a time converts the source code into machine language
    12·1 answer
  • You are trying to log in to your old computer, and can't remember the password. You sit for hours making random guesses... I'm s
    10·1 answer
  • William is an HR manager in a textile-manufacturing firm. He is creating a file on the hours each employee worked during the las
    6·2 answers
  • What are the things that a computer literate understands?Name thems.​
    14·1 answer
  • Anyone trying to play fortnite ? im bored lol
    6·2 answers
  • What two functions does tcp/ip perform?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!