
Write a program that reads in investment amount, annual interest rate, and number of years, and displays the future investment value using the following formula:
futureInvestmentvalue = investmentAmount x (1 + monthlyInterestRate)numberOfyears *12

import java.util.*;
import java.text.*;
class FutureInvestmentRate
{
public static void main(String[] args)
{
DecimalFormat df=new DecimalFormat("##.##");
Scanner input=new Scanner(System.in);
System.out.print("Enter investment amount: ");
double amount=input.nextDouble();
System.out.print("Enter monthly interest rate: ");
double rate=input.nextDouble();
System.out.print("Enter number of years: ");
int years=input.nextInt();
double v1=1+rate;
double v2=v1*years*12;
double futureInvestmentvalue = amount * v2;
System.out.println(df.format(futureInvestmentvalue));
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.