In: Computer Science
Write a program in java that asks the name of the buyer and the number of shares bought. Your program must then calculate and display the following. sold stock/shares to the general public at the rate of $24.89 per share. Theres a 2 percent (2%) commission for the transaction.
Outputs need
Amount paid for buying the stock ($)
Amount paid for the commission ($)
Total amount ($)
<ShareAmount.java>
import java.util.*;
import java.lang.*;
import java.io.*;
public class ShareAmount {
public static void main (String[] args) throws
java.lang.Exception
{
double buying_Amount, commission_Amount;
double total;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the name of buyer : ");
String name = reader.readLine();
System.out.print("Enter the number of shares bought : ");
BufferedReader rd = new BufferedReader(new
InputStreamReader(System.in));
String n = rd.readLine();
int shares = Integer.parseInt(n);
buying_Amount = shares*24.89;
System.out.print("Amount paid for buying the stock ($) = " +buying_Amount);
commission_Amount = buying_Amount*0.02;
System.out.print("Amount paid for the commission ($) = " +commission_Amount);
total = buying_Amount+commission_Amount;
System.out.print("Total amount ($) = " +total);
}
}