Java please help asap *6.7 (Financial appli cat ion: Compute the future investme
ID: 643664 • Letter: J
Question
Java please help asap *6.7 (Financial appli cat ion: Compute the future investment value) Write a method that computes future investment value at a given interest rate for a specified number of years. The future investment is determined using the formula in Programming Exercise 2.21. Use the following method header: public static double future lnvestmentvalue( double investment Amount, double monthlylnterest Rate, int years) For example, future lnvestmentValue(10000, 0.05/12, 5) returns 12833.59. Write a test program that prompts the user lo enter the investment amount (e.g., 1000) and the interest rate (e.g., 9%) and prints a table that displays future valuc for the years from 1 to 30, as shown below:Explanation / Answer
import java.util.Scanner;
public class FutureInvestment {
public static double futureInvestmentValue(double investmentValue, double monthlyInvestmentRate, int years){
double amount = 0;
return investmentValue * Math.pow((1 + monthlyInvestmentRate), 12 * years);
}
public static void main(String args[]){
Scanner in = new Scanner(System.in);
System.out.print("The amount invested: ");
double amount = in.nextDouble();
System.out.print("Annual interest rate: ");
double rate = in.nextDouble();
System.out.println("Years Future Value");
for(int i = 1; i <= 30; ++i){
System.out.printf("%d %.2f ", i, futureInvestmentValue(amount, rate / 100 / 12, i));
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.