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
Why do arthitects prefer memory dump to be in base 16​
gogolik [260]

Answer:

Memory dump in  base 16​ is human friendly

Explanation:

Hexadecimal numbers are human friendly and hence it is very easy to express the binary number in a more human-friendly as compared to any other base number systems. It is also used to trace errors in the storage

hence, the Architects prefer memory dump to be in base 16​

7 0
2 years ago
Write a function which the counts the number of odd numbers and even numbers currently in the stack and prints the results.
Lerok [7]

Answer:

See the code below and the algorithm explanation on the figure.

Explanation:

The explanation in order to get the answer is given on the figure below.

Solving this problem with C. The program is given below:

#include <stdio.h>

int main(void) {

   int n, Even=0, Odd=0, Zeros=0;  

   for (;;) {

       printf("\nEnter the value the value that you want to check(remember just integers): ");

       //IF we input a non-numeric character the code end;

       if (scanf("%d", &n) != 1) break;

       if (n == 0) {

           Zeros++;

       }

       else {

           if (n % 2) {

               Even++;

           }

           else {

               Odd++;

           }

       }

   }  

   printf("for this case we have %d even, %d odd, and %d zero values.", Even, Odd, Zeros);

   return 0;

}

5 0
2 years ago
One type of CAPTCHA is ________. a rootkit virus the wavy hard-to-read letter and number sequence that you type to prove that yo
sergejj [24]
<h2>password method</h2>

Explanation:

Rootkit virus is one type of virus which is hidden about its existence and tries to affect the maximum number of system.

Password method: This is a graphical method to identify the text hidden in the signature and confirming that it is not a robot or any other system to protect the system from hacking. This would be really hard-to-read and thus ensures safety.

Antivirus software: This is a system to protect the system, when the virus tries to attack the system. An indication will be given through the software to the user.

4 0
3 years ago
="Jack"&amp;"$"&amp;"Jill". What will be the output of this formula?​
natita [175]
I’m so confused on this but hey here’s this

3 0
2 years ago
WILL GIVE BRAINIEST! Your users are young children learning their arithmetic facts. The program will give them a choice of pract
Ierofanga [76]

In python:

numA = [4, 1, 6, 10, 2, 3, 7, 9, 11, 12, 5, 8]

numB = [2, 12, 10, 11, 1, 3, 7, 9, 4, 8, 5, 6]

while True:

   i = 0

   userChoice = input("Adding or Multiplying? (a/m) ")

   if userChoice == "a":

       while i < len(numA):

           answer = int(input("What is {} + {} ".format(numA[i],numB[i])))

           if answer == numA[i] + numB[i]:

               print("Correct!")

           else:

               print("That's incorrect. The right answer is {}".format(numA[i] + numB[i]))

           i += 1

   elif userChoice == "m":

       while i < len(numA):

           answer = int(input("What is {} * {} ".format(numA[i], numB[i])))

           if answer == numA[i] * numB[i]:

               print("Correct!")

           else:

               print("that's incorrect. The right answer is {}".format(numA[i] * numB[i]))

           i += 1

4 0
3 years ago
Other questions:
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    15·1 answer
  • Which windows tool can you use to find out if the hard drive is slowing down windows performance?
    9·1 answer
  • Given: an int variable k, an int array current Members that has been declared and initialized, an int variable memberID that has
    11·1 answer
  • Print a countdown from n to 1 The function below takes one parameter: an integer (begin). Complete the function so that it print
    8·1 answer
  • Late at night, some traffic signals change patterns and become _____.
    9·2 answers
  • Write a function named firstLast2 that takes as input an array of integers and an integer that specifies how many entries are in
    14·1 answer
  • + Use for loop to print numbers from 100 to 10
    11·1 answer
  • LAB: Convert to binary - methods
    11·1 answer
  • Select the correct word to complete the sentence.
    8·1 answer
  • Assume a future where security counter measures against DoS attacks are much more widely implemented than at present. In this fu
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!