5. Write a Java method to compute the future investment value at a given interest rate for a specified number of years.
class Main
{
static double getFutureValue(double amt, double roi, int time){
double fv = amt*Math.pow((1+(roi/100)), time);
return fv;
}
public static void main(String[] args){
System.out.println("Amount = 15000");
System.out.println("Rate of Interest = 10");
System.out.println("Years = 6");
System.out.printf("Your Future Value is %.2f" , getFutureValue(15000.0, 10.0, 6));
}
}
OUTPUT:
Amount = 15000
Rate of Interest = 10
Years = 6
Your Future Value is 26573.42