-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathA2Q11.java
23 lines (22 loc) · 1000 Bytes
/
A2Q11.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//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 * (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.
import java.util.Scanner;
public class A2Q11
{
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.print("Enter investment amount: ");
double amount = input.nextDouble();
System.out.print("Enter annual interest rate in percentage: ");
double monthlyInterestRate = input.nextDouble();
monthlyInterestRate /= 1200;
System.out.print("Enter number of years: ");
int years = input.nextInt();
double futureInvestmentValue = amount * Math.pow(1 + monthlyInterestRate, years * 12);
System.out.println("Accumulated value is $" + futureInvestmentValue);
}
}