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
You have a number of digital pictures you recently took on your smartphone. You would like to share these pictures with all of y
mafiozo [28]

Answer:

A cloud is a way of saying shared storage. Basically let's say you are in a classroom. Remember those cool projectors that projected a transparent drawn on sheet? it's like taking your picture and projecting it for all to see, but only for those individuals in the classroom. You can even lock the door to protect it(password protect) and only those with the key(password) get in!

Explanation:

You can use Google Drive

Microsoft Azure

OneDrive

Dropbox

many others.

7 0
4 years ago
Which of the following are types of home internet service? Check all that apply
Aleks04 [339]
Need options???????????
6 0
4 years ago
Select the three early tools that were prototypes of modern farming tools used for harvesting crops.
KatRina [158]
I believe the answer is Spears, sickles, and cradles. I hope that helps!
6 0
4 years ago
Do you have to make a account of Windows 10?
shepuryov [24]

Answer: No!

Explanation: You can make your account where and whenever!

6 0
4 years ago
The most commonly used software in the school systems that include word processor, spreadsheet, database management system, and
Irina-Kira [14]
Microsoft office
...........
4 0
4 years ago
Other questions:
  • Currently, there are two major techniques used to develop programs and their procedures. name and describe them. html editor key
    11·1 answer
  • When did project management first emerge as a profession
    6·1 answer
  • For this lab, youhave to write a programnamedseriesFunction.cthat prompts user to enter two values, x and n. Then it would use a
    11·1 answer
  • Assume that someone dictates you a sequence of numbers and you need to write it down. For brevity, he dictates it as follows: fi
    14·1 answer
  • Suppose you have two tables: officer and gentleman. what question(s) can be asked by using the union operator?
    11·1 answer
  • Under which menu option of a word processing program does a callout appear?
    7·2 answers
  • Suppose that the instruction format for a modified Little Man Computer requires two consecutive locations for each instruction.
    5·1 answer
  • Please help i will give you brainlest!!!!!!!!!
    6·1 answer
  • What is the importance of shape in graphic design?​
    5·2 answers
  • Which testing is used for a program's individual components functionality testing?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!