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
Ndcdeviceid?????????????????????​
butalik [34]

YESS

Explanation:

YESSssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss

7 0
2 years ago
What command do you type in the search box to access the command line intrface in windows?
Whitepunk [10]
Cmd.exe



------------------------------------------
3 0
3 years ago
Write a Python program that inputs an integer between 0 and 1000 and adds all the digits in the integer. For example, if integer
nignag [31]

I've included my code in the picture below.

5 0
3 years ago
Can anyone answer this ​
Ivenika [448]

Answer:

I dont see the question

Explanation:

7 0
2 years ago
Computer _____ begins with regular maintenance of the computer system such as firewalls, antivirus programs, defragmentation, de
Dima020 [189]
Computer checkup/maintenance. You forgot to mention windows updates, it is critical to perform that action as well cause of the recent ransomeware malware that is going around lately and Microsoft and other OS vendors yes even Apple have released patches to prevent it spreading even further. 
4 0
3 years ago
Other questions:
  • In C++ Please :
    6·1 answer
  • Design and implement an application that plays the Hi-Lo guessing game with numbers. The program should pick a random number bet
    13·1 answer
  • what are the benefits of VolP? select all that apply. A:cheaper printings B:clearer calls C: faster download D: increased effici
    11·2 answers
  • Which of the following is a key feature of SmoothWall? Weak traffic graphs and bandwidth bars Universal Plug and Play support DM
    7·1 answer
  • Write a function definition for a function which takes one parameter and returns twice that parameter
    12·1 answer
  • Only for study<br><br>Or open Meet and enter this code: bqa-ivfs-ach​
    11·2 answers
  • Second Largest, Second Smallest Write a program second.cpp that takes in a sequence of integers, and prints the second largest n
    15·1 answer
  • A file named loan.html, write an HTML document that looks similar to figure 9-7 in the textbook. Write four functions with these
    8·1 answer
  • marianne needs to create a version of her slide presentation that does not include all the slides and will be used for a particu
    9·1 answer
  • Read the scenario below, and then choose the right type of computer for each person from the drop-down menus. Three of your frie
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!