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
you are currently logged in using the badams account. you want to view the contents of the /etc/inittab file, but you are not al
Blizzard [7]

The command that can be used to view the file is su -c "cat /etc/inittab" -l. The command in computer is a code that is used to tell (someone) to do something in a forceful and often official way.

A command in computer refers to a single order from a user to the computer's operating system or to an application to show a service, such as "Show me all my files" or "Run this program for me.

Kind of command there are:

  1. Group management commands.
  2. Array management commands.
  3. Global commands.

The commands are a kind of sentence to tell someone to do something. The other kind of command are: questions, exclamations and statements.

Learn more about the command, here brainly.com/question/13994833

#SPJ4

4 0
1 year ago
a value-returning method must specify as its return type in the method header. question 18 options: a) an int b) a double c) a b
Olenka [21]

An int must be specified in the method header as the return type for a value-returning method

<h3>What is an int?</h3>

A whole number that can be positive, negative, or zero is called an integer. It is not a fraction. -5, 1, 5, 8, 97, and 3, 043 are some examples of integers. 1.43, 1 3/4, and 3.14 are a few examples of numbers that are not integers.

The compiler includes a fundamental variable type called int, which stands for "integer" and is used to define numeric variables that carry entire integers. Float and double are additional data types.

A basic data type is the Java int keyword. Declaring variables is done using it. Additionally, it can be used with methods that return values of the integer type. It is capable of storing a 32-bit signed, two's complement integer. In the Internet's Domain Name System, the domain name int is a sponsored top-level domain.

To learn more about an int refer to:

brainly.com/question/27415982

#SPJ4

5 0
1 year ago
The entirety of a packet at one layer becoming the payload section at another layer is known as
marusya05 [52]
The best answer to this question would be encapsulation

Payload data is part of a packet that is within a TCP or a UDP. It is the actual or essential data that is being carried within a packet. For instance, a layer 2 Frame has a payload of a layer 3 packet and a layer packet has a payload of layer 4 Segment. This simply can be called encapsulation. Each layer in the examples mentioned builds a PDU by adding a header containing control information to the PDU.  



8 0
3 years ago
Read 2 more answers
HELLLLLP ill make you brainiest and ill give u a lot of points if you HELP ME Directions Part One.
Vesnalui [34]
The revised email is shown below: 
E-mail A: Good Day! Is it possible that I will be receiving the training manual this morning because I will be needing it for my next shift. 
E-mail B: A customer has a concern regarding the bill that she paid. In the end, she realized that it was a mistake on her part and she wants to call again tomorrow. 

6 0
4 years ago
Read 2 more answers
When u look at a green object through red glass the object will appear
levacccp [35]
I think it looks red, I tried simulating it in google drive and photoshop, I'm sorry if I am false
4 0
4 years ago
Read 2 more answers
Other questions:
  • 2. Billys teacher asked him to type a report about asian food. Which paragraph format should he use?
    12·2 answers
  • Anyone want to join my dîšćòrd
    8·2 answers
  • You have noticed that one of your DNS servers has possibly been compromised. You believe that a cached DNS entry for your domain
    8·1 answer
  • Assume that an array of integers named a that contains exactly five elements has been declared and initialized. Write a single s
    15·1 answer
  • Which statement about the subject line is true? The subject line can be found just below the message box. The subject line is ma
    13·2 answers
  • To move an object to the bottom of the stack, click the Send Backwards arrow and then click Send to Back in the Arrange group on
    7·1 answer
  • What is the difference between an activity inventory and an object inventory?
    8·1 answer
  • What is the most vulnerable information that should be protected to prevent unauthorized access to your online files and records
    8·1 answer
  • Which of the following is a mathematical function defined in the sql standard?
    6·1 answer
  • 2023 murano’s available intelligent awd adjusts the ________ to help maintain cornering control.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!