Project: Calculating Future Investment Value Problem Description: Write a progra
ID: 3562755 • Letter: P
Question
Project: Calculating Future Investment Value
Problem Description:
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:
and displays the future investment value using the following formula:
futureInvestmentValue =
investmentAmount * (1 + monthlyInterestRate)numberOfYears*12
For example, if you enter amount 1000, annual interest rate 3.25%, and number of years 1, the future investment value is 1032.98.
Hint: Use the Math.pow(a, b) method to compute a raised to the power of b.
Here is a sample run:
Sample 1:
Enter investment amount: 1000
Enter annual interest rate: 4.25
Enter number of years: 1
Accumulated value is 1043.34
Sample 2:
Enter investment amount: 1000
Enter annual interest rate: 4.25
Enter number of years: 1
Accumulated value is 1043.34
Explanation / Answer
import java.util.*;
public class untitled{
public static void main(String []args)
{double invest,rate,future;
int years;
Scanner in=new Scanner(System.in);
System.out.print("Enter investment: ");
invest=in.nextDouble();
System.out.print("Enter interest rate: ");
rate=in.nextDouble();
System.out.print("Enter number of years: ");
years=in.nextInt();
future=invest*Math.pow((1+rate/1200.),years*12);
System.out.println("investment: $"+invest);
System.out.println("yearlyrate: "+rate+"%");
System.out.printf("future value after "+years+" years:$%.2f ",future);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.