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
Hydraulic pressure is the same throughout the inside of a set of brake lines. What determines the amount of resulting mechanical
cestrela7 [59]

Answer: 1000 square ponds of force hope you know the answer

Explanation: i guessed

7 0
3 years ago
What is the recommended procedure for disconnecting an external hard drive to avoid losing data?
Zina [86]

Answer:

Instruct the operating system to eject the drive before unplugging it.

Explanation:

3 0
3 years ago
What is the fifth and final stage in the process of media production
Mama L [17]

edit is the 5th and distribute is the final stage in process of media production


6 0
3 years ago
When you code a column list in an INSERT statement, you can omit columns with default values and columns that allow ____________
stiks02 [169]

Answer:

NULL is the correct answer of this question.

Explanation:

The insert statement is used for inserting a column list into the database this statement is an under Data Manipulation language.When we insert any column into the database there is always a null value stored.

  • Insert statement is used to insert the data into the database .
  • To insert data following syntax is used:-

         insert into tablename (column data type).

  • When we insert any data into the database the default value is stored is bull.
6 0
3 years ago
PLEASE HELP
Lunna [17]

Answer:

Spreadsheets is a software like Microsoft excel

3 0
3 years ago
Read 2 more answers
Other questions:
  • An attribute whose value uniquely identifies an object is called a(n) _______.​
    15·1 answer
  • How many parameters go into the function sum, and how many return values come out of the function sum? function sum(first, secon
    6·1 answer
  • What to buy instead of the hp chromebook 13
    15·1 answer
  • To maintain her audience's confidence in her, what should kiara not do while delivering her presentation?
    10·1 answer
  • A write once, read many (worm) disc is a common type of _____.
    6·1 answer
  • Write the definition of a class WeatherForecast that provides the following behavior (methods): A method called set_skies that h
    13·1 answer
  • A group of developers for a startup company store their source code and binary files on a shared open-source repository platform
    14·1 answer
  • Give me 4 examples of things to consider as a sound designer?<br> HURYYYYY IM TIMED
    11·1 answer
  • A new user needs access to their files in iCloud without relying on the operating system (OS). How would the user access the App
    13·1 answer
  • Try to crack the code:
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!