Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a method that computes future investment value at a given interest rate fo

ID: 3565135 • Letter: W

Question

Write a method that computes future investment value at a given interest rate for a specified number of years.

Use the following method header:

public static double futureInvestmentValue(

double investmentAmount, double monthlyInterestRate, int years)

For Example, futureInvestmentValue(10000, 0.05/12,5) returns 12833.59.

Write a Java test program that prompts the user to enter the investment amount (e.g.,1000) and the interset rate (e.g.,9%) and prints a table that displays the futute value for the years from 1 to 30, as shown below:

_____________________________________________________________________

Ex)

The amount invested: 1000

Annual interest rate: 9

Years             Future Value

1                     1093.80

2                      1196.41

...

29                    13467.25

30                    14730.57

Explanation / Answer


import java.util.Scanner;


public class futureInvestmentValue
{

public static void main(String args[])
{
Scanner in =new Scanner(System.in);
double investmentAmount;
double monthlyInterestRate;
int years;
System.out.println("Please enter investment amount");
investmentAmount =in.nextDouble();
System.out.println("Please enter interest rate monthly");
monthlyInterestRate=in.nextDouble();
futureInvestmentValue(investmentAmount, monthlyInterestRate, 30);
  
}
public static double futureInvestmentValue(double amount,double rate ,int years)
{
System.out.println("The amount invested: "+amount);
System.out.println("Annual interest rate: "+rate);
System.out.println("Years Future Value");
for(int i=1;i<=years*12;i++)
{
amount = amount + amount *rate /100 ;
if(i %12 == 0)
{
System.out.println(i/12 +" "+amount);
}
}
  
return amount;
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote