Question

In: Computer Science

Write a program in java that asks the name of the buyer and the number of...

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 ($)

Solutions

Expert Solution

<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);
   }

}


Related Solutions

Write a program IN JAVA that asks the user for a number. The program should check...
Write a program IN JAVA that asks the user for a number. The program should check the number to ensure that it is valid (if not, the user should enter a valid number to continue.) The program should print out all of the prime numbers from 2 up to the number, with up to 10 numbers per line. (Recall: A prime number is a number that is only divisible by itself and 1.) The code should ask the user if...
Write a java program that asks the user for a number n and gives them the...
Write a java program that asks the user for a number n and gives them the possibility to choose between computing the sum and computing the product of 1,…,n. Example of running this program: Enter an integer number n: __7________ Enter Sum or Product: __Sum__________________________________ Program output: Sum of 1 ... 7 Sum or Product: Sum Sum = 28 Now second sample of second execution Enter an integer number n: __5__________________________________ Enter Sum or Product: __Product__________________________________ Program output:  Product of 1...
In Java: Write a program that generates a random number and asks the user to guess...
In Java: Write a program that generates a random number and asks the user to guess the number and keeps track of how many guesses it took If the user input is negative or zero then the loop must stop reading further inputs and display how many guesses they used If they guess the correct number display a message telling them they got it and exit the program If they guess the wrong number (but still a legal guess) you...
Write a java program which asks the user to enter name and age and calls the...
Write a java program which asks the user to enter name and age and calls the following methods: printName(): Takes name as parameter and prints it 20 times using a while loop. printAge(): Takes age as parameter and prints all the numbers from 1 up to age. Write a java program that will print first 10 multiples of 3 in a single line.
Java Program 1. Write a program that asks the user: “Please enter a number (0 to...
Java Program 1. Write a program that asks the user: “Please enter a number (0 to exit)”. Your program shall accept integers from the user (positive or negative), however, if the user enters 0 then your program shall terminate immediately. After the loop is terminated, return the total sum of all the previous numbers the user entered. a. What is considered to be the body of the loop? b. What is considered the control variable? c. What is considered to...
Write a Java program that calculates a random number 1 through 100. The program then asks...
Write a Java program that calculates a random number 1 through 100. The program then asks the user to guess the number.If the user guesses too high or too low then the program should output "too high" or "too low" accordingly.The program must let the user continue to guess until the user correctly guesses the number. ★Modify the program to output how many guesses it took the user to correctly guess the right number
Write a JAVA program that asks a user to specify the number of months, investment amount...
Write a JAVA program that asks a user to specify the number of months, investment amount and compound interest rate in % (per annum) • Your program should then print each month, starting balance, interest earned and ending balance • Your program is not expected to handle more than 5 months • The balance and ending balance should be printed rounded to 2 decimal places • You should utilise String.format() to display each line of the output. This function can...
Write a Java program which asks customer name, id, address and other personal information, there are...
Write a Java program which asks customer name, id, address and other personal information, there are two types of customers, walk-in and credit card. The rates of items are different for both type of customers. System also asks for customer type. Depending upon customer type, it calculates total payment. A credit-card customer will pay 5 % extra the actual price. Use object-oriented concepts to solve the problem. Define as many items and prices as you want. Example Output: Enter Name...
Python: Write a program that asks the user for the name of a file. The program...
Python: Write a program that asks the user for the name of a file. The program should display the contents of the file line by line.
Write a program that asks the user to enter the name of a file, and then...
Write a program that asks the user to enter the name of a file, and then asks the user to enter a character. The program should count and display the number of times that the specified character appears in the file. Use Notepad or another text editor to create a sample file that can be used to test the program. Sample Run java FileLetterCounter Enter file name: wc4↵ Enter character to count: 0↵ The character '0' appears in the file...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT