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
dsp73
3 years ago
15

Write a Java program to calculate and display the following: 1. the dollar amount paid for the shares 2. the dollar amount of th

e shares sold 3. the total transaction fee paid to the broker (including both buy and sale) 4. the amount of profit (or loss) made after selling the shares.
Computers and Technology
1 answer:
Trava [24]3 years ago
8 0

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

       System.out.print("Please Enter your name: ");

       Scanner in = new Scanner (System.in);

       String name = in.nextLine();

       System.out.print("Please Enter Total Number of Shares Bought: ");

       int totalShares = in.nextInt();

       System.out.print("Welcome "+name+" Please How much did you pay for each unit of share: ");

       double buyAmount = in.nextDouble();

       System.out.print( "Please How much did you sell each unit: ");

       double sellAmount = in.nextDouble();

       System.out.print("Please Enter the Total transaction fees paid to the broker (For buying and selling): ");

       double transFee = in.nextDouble();

       //Outputs

       System.out.println("\t TRANSACTION REPORT FOR "+name);

       System.out.println("Total Shares Bought is: "+totalShares);

       System.out.println("Total Amount paid for the shares is: "+buyAmount*totalShares);

       System.out.println("Total Amount for Selling of the share is "+sellAmount*totalShares);

       System.out.println("Total transaction fees is: "+ transFee);

       // Output Profit or Loss

       if(((sellAmount*totalShares)-(buyAmount*totalShares)+(transFee))>0){

           System.out.println("The total amount of profit is " +

                   " "+((sellAmount*totalShares)-(buyAmount*totalShares)+(transFee)));

       }

       else {

           System.out.println("The total amount of loss is " +

                   " "+((sellAmount*totalShares)-(buyAmount*totalShares)+(transFee)));

       }

   }

}

Explanation:

  1. Receive all user inputs with the Scanner Class
  2. Calculate total amount for shares bought by multiplying unit price by total number bought
  3. Calculate total amount for sale of the share in same way as step 2 above
  4. determine profit and loss by subtracting (step2 from step3)
  5. Print out profit or loss
You might be interested in
What are the specifications of mine shaft head gear​
svetlana [45]

Answer:

the depth of the shaft,

the carrying load of the skip and the mass of the counterweight,

the approximate size of the winding drum,

the approximate height of the headgear and the sheave wheel

4 0
3 years ago
Read 2 more answers
What is the memory of a computer called
Nataliya [291]
It is called Ram in another term for memory :)
6 0
3 years ago
Read 2 more answers
What do we call exceptions to the exclusive rights of copyright law?
Studentka2010 [4]

Answer:

Fair use

Explanation:

I don't know if this is correct but Its the best option.

4 0
3 years ago
A a a a I don't need help!?
Arlecino [84]

Answer:

ok

Explanation:

ok

6 0
3 years ago
11.How would you characterize the relative range of paths forecasted by the various computer models on August 25
larisa86 [58]

Answer:

Following are the solution to this question:

Explanation:

There is some difference between both the path expected by different computer simulations on 25 August. There is also some variance between 50 km to 500 km in the predicted route but the path is also unique in each model evaluation. It might be because any and every possible situation is repeated by the computer program. Many simulations will focus mostly on variations of strain, one might focus on the temperature variation, or one might concentrate on certain variables. But each model suggests all and every parameter which is inserted during a very photographer's encoding. There are therefore several possibilities of variability in forecasting the Hurricane's course. Here and some forecasts have shown that hurricanes would pass through Florida fully, and also some models have shown that hurricanes would pass thru the Gulf Coast, accompanied by the areas of Mississippi or Louisiana. This is the real difference in the direction of these models.

3 0
3 years ago
Other questions:
  • Write an exception class named InvalidTestScore. Modify the TestScores class you wrote in Part I so that it throws an InvalidTes
    10·1 answer
  • On what basis can you categorize the generations of computers?
    5·1 answer
  • Create a program that generates a report that displays a list of students, classes they are enrolled in and the professor who te
    11·1 answer
  • What do you find when you first open a word processor and how do you adjust the document Indentitions
    6·1 answer
  • What are the paparazzi?
    8·1 answer
  • Which of the following is NOT a type of insurance fraud?
    14·2 answers
  • PLEASE ANSWER THIS ASAP‼️
    10·2 answers
  • Would you consider upgrading Maxine’s wardrobe a need or a want?
    11·1 answer
  • ! (( i > ( f + 1)) es verdadero o falso segun la logica de programación.
    14·1 answer
  • How do you initiate a sprite’s actions in a scene?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!