hey everyone,
i have to write a method that computes future investment value at a given interest rate for a specified number of years.
Write a test program that prompts the user to enter the investment amount, and the interest rate, and prints a table that displays future value for the years 1 to 30.
this is the code that i have so far:
import java.util.Scanner;
public class Investment
{
public static void main (String []args)
{
double futureInvestmentValue;
double investmentAmount;
double monthlyInterestRate;
double rate;
int years;
Scanner input = new Scanner (System.in);
System.out.print("Enter the amount invested:");
investmentAmount = input.nextDouble();
System.out.print("Enter the annual interest rate:");
rate = input.nextDouble();
System.out.print("Enter number of years:");
years = input.nextInt();
monthlyInterestRate = rate/1200;
futureInvestmentValue = investmentAmount*Math.pow((1+monthlyInterestRate),years*12);
System.out.println("The future value is " +futureInvestmentValue);
}
}
****the part that i need help with is, how do i print a table that displays the future value for the years from 1 to 30? and i guess i dont need to prompt the user for the years then.
if anyone could please help me, it will be greatly appreciated.