-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExercise06_07.java
More file actions
32 lines (28 loc) · 1.14 KB
/
Copy pathExercise06_07.java
File metadata and controls
32 lines (28 loc) · 1.14 KB
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
29
30
31
32
import java.util.Scanner;
/*
* 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.
*/
/**
*
* @author jorda
*/
public class Exercise06_07 {
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.println("Enter the investment amount: ");
double investmentAmout = input.nextDouble();
System.out.println("Enter the interest rate: ");
double monthlyInterestRate = input.nextDouble();
monthlyInterestRate = (monthlyInterestRate / 12)/100;
System.out.println("Years Future Value");
for (int i = 1; i <= 30; i++) {
System.out.printf("%2d %8.2f\n", i, futureInvestmentValue(investmentAmout, monthlyInterestRate, i));
}
}
public static double futureInvestmentValue(double investmentAmount, double monthlyInterestRate, int years){
double futureInvestmentValue = investmentAmount * Math.pow((1 + monthlyInterestRate), (years*12));
return futureInvestmentValue;
}
}