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
What does it mean by MYRIAD of data?
pentagon [3]

Answer:

The term Myriad means an indefinitely large number of things. And when we say Myriad of data, we mean an indefinitely large amount of data like in Petabytes.

Explanation:

What it does implies is that you are dealing with a large amount of data. And hence we are dealing with something like bigData. And hence, technologies related to BigData are going to operate. And this term is used as a noun as well as an adjective when we talk about English. And hence, you can use it with "a" or without the "a" as well. It has been a part of reputable English and has been repeatedly used by top authors like Milton.

5 0
3 years ago
Given four inputs: a, b, c & d, where (a, b) represents a 2-bit unsigned binary number X; and (c, d) represents a 2-bit unsi
Amiraneli [1.4K]

Answer:

z = a.c' + a.b.d' + b.c'.d'

Explanation:

The truth table for this question is provided in the attachment to this question.

N.B - a' = not a!

The rows with output of 1 come from the following relations: 01 > 00, 10 > 00, 10 > 01, 11 > 00, 11 > 01, 11 > 10

This means that the Boolean expression is a sum of all the rows with output of 1.

z = a'bc'd' + ab'c'd' + ab'c'd + abc'd' + abc'd + abcd'

On simplification,

z = bc'd' + ab'c' + ac'd' + ac'd + abc' + abd'

z = ac' + abd' + bc'd'

Hope this helps!

6 0
3 years ago
16.
dimaraw [331]
  • Answer:

<em>r = 15 cm</em>

  • Explanation:

<em>formula</em>

<em>V = πr²×h/3</em>

<em>replace</em>

<em>4950 = 22/7×r²×21/3</em>

<em>4950 = 22/7×r²×7</em>

<em>4950 = 22×r²</em>

<em>r² = 4950/22</em>

<em>r² = 225</em>

<em>r = √225</em>

<em>r = √15²</em>

<em>r = 15 cm</em>

3 0
2 years ago
This is more opinionated than question-based.
kozerog [31]

I think the Iphone is better the Google Pixels. That's just my opinion but some people like google pixels better.

7 0
3 years ago
Simplify the Boolean expression (AB(C + BD) + AB]CD.
finlep [7]

Explanation:

Simplify the Boolean expression (AB(C + BD) + AB]CD.

6 0
2 years ago
Read 2 more answers
Other questions:
  • When a crystal grows in unrestricted space, how does growth occur?
    14·2 answers
  • Match each storyboarding technique with its appropriate description
    9·1 answer
  • Select all the items that determine your preference for a concert ticket. a) band that is playing b) date of the concert c) pric
    7·1 answer
  • Date criteria are automatically enclosed in ____ when entered in a query design.
    11·1 answer
  • Design and implement a class called Sphere that contains instance data that represent the sphere’s diameter. Define the Sphere c
    6·1 answer
  • 9.4 Code Practice: Your task is to determine whether each item in the array above is divisible
    14·1 answer
  • HELLO <br> any edmentum people out there.
    15·2 answers
  • This is science I just couldn’t find it
    15·1 answer
  • 20 POINTS! Which music making software is better? Ableton Live or Logic Pro? Name the advantages and disadvantages of each one!
    7·2 answers
  • What is e banking effects
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!