Below java program for calculate future investment value.
Here calculate s using the formula futureInvestmentValue
=investmentAmount x (1 + monthlyInterestRate)^numberOfYears*12.
Output:
Java code here.
package swain.swain;
import
java.util.Scanner;
public class
CalculateFutureInvestmentValue {
public static void main(String[] args) {
Scanner
input = new Scanner(System.in);
System.out.println("Enter
investment amount:");
double investmentAmount = input.nextDouble();
System.out.println("Enter
annual interest rate in percentage:");
double monthlyInterestRate = input.nextDouble();
System.out.println("Enter
number of years:");
double numberOfYears = input.nextDouble();
double futureInvestmentValue = investmentAmount * Math.pow((1
+ (monthlyInterestRate / 1200)), (numberOfYears * 12));
futureInvestmentValue = (int) (futureInvestmentValue * 100) / 100.0;
System.out.println("Accumulated
value is " + futureInvestmentValue + "\n");
}
}
No comments:
Post a Comment