In Java: Provide an application that calculates the money returned by an inverst
ID: 3788428 • Letter: I
Question
In Java:
Provide an application that calculates the money returned by an inverstor after a year where the number of shares he bought, the price of each share and the percentage of yearly dividend are provided from the keyboard. The output is in the following format with the number displayed in columns. For example: if the number of shares = 1500 with $45.29 per share and percentage of yearly dividend is 3.5% .
The formula to calculate the money returned is: Total money invested = Price of one share * number of shared
Total money returned: total money invested + total money invested * percentage of yearly dividend
Explanation / Answer
import java.util.*;
public class Shares
{
public static void main (String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter the number of shares");
int shares = scan.nextInt(); // input number of shares
System.out.println("Enter the price of one share");
double pricePerShare = scan.nextDouble(); //input price per share
System.out.println("Enter the percentage of yearly dividend");
double perYearlyDiv = scan.nextDouble(); //input percentage of yearly dividend
double totalMoneyInvested = pricePerShare * shares; //compute total money invested
System.out.println("Total money invested : $"+totalMoneyInvested);
double totalMoneyReturned = totalMoneyInvested + totalMoneyInvested * perYearlyDiv; //compute total money returned
System.out.println("Total money returned : $"+totalMoneyReturned);
}
}
output:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.