-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExercise02_21.java
28 lines (26 loc) · 1005 Bytes
/
Exercise02_21.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package Chapter2;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.Scanner;
/**
*
* @author jorda
*/
public class Exercise02_21 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter the investment amount: ");
double investmentAmount = input.nextDouble();
System.out.println("Enter annual interest rate: ");
double annualInterestRate = input.nextDouble();
System.out.println("Enter the number of years: ");
double nOfYears = input.nextDouble();
double monthlyInterestRate = annualInterestRate/1200.0;
double temp = Math.pow((1 + (monthlyInterestRate)), nOfYears*12);
double futureInvestmentValue = investmentAmount * temp;
System.out.println("Future value is: " + futureInvestmentValue);
}
}