I am new in Java and I am supposed to calculate the interest rate development of 1000 € in 10 years with an increasing percentage (3%, 4%, 5%, 6%, 7%). I have many troubles figuring out how to make the calculation between the two arrays. The real difficulty is to put the 1000 € in the first [0] line of the bi-dimensional array (year 0) and to add the rate every year on the next line of the array. This is was I was able to do until now but now I am completely stuck:
public class zinsenEntwicklung {
/**
* @param args
*/
public static void main(String[] args) {
final int N1 = 11;
final int N2 = 5;
double anfang = 1000;
double zinsenTable[] = {0.03, 0.04, 0.05, 0.06, 0.07};
double b[][] = new double[N1][N2];
System.out.println("Jahr");
for (int i = 0; i < 11; i++) {
System.out.print(i + "\t");
for (int j = 0; j < zinsenTable.length; j++) {
for (int k = 0; k < i; k++) {
b[i][j] = (anfang * zinsenTable[j]) + anfang;
}
System.out.print(b[i][j] + "\t");
}
System.out.print("\n");
}
}
}
What I should get:
Jahr 3% 4% 5% 6% 7%
0 1.000,00 1.000,00 1.000,00 1.000,00 1.000,00
1 1.030,00 1.040,00 1.050,00 1.060,00 1.070,00
2 1.060,90 1.081,60 1.102,50 1.123,60 1.144,90
...
10 1.343,92 1.480,24 1.628,89 1.790,85 1.967,15
What I am getting:
Jahr
0 0.0 0.0 0.0 0.0 0.0
1 1030.0 1040.0 1050.0 1060.0 1070.0
2 1030.0 1040.0 1050.0 1060.0 1070.0
3 1030.0 1040.0 1050.0 1060.0 1070.0
4 1030.0 1040.0 1050.0 1060.0 1070.0
5 1030.0 1040.0 1050.0 1060.0 1070.0
6 1030.0 1040.0 1050.0 1060.0 1070.0
7 1030.0 1040.0 1050.0 1060.0 1070.0
8 1030.0 1040.0 1050.0 1060.0 1070.0
9 1030.0 1040.0 1050.0 1060.0 1070.0
10 1030.0 1040.0 1050.0 1060.0 1070.0
I would be really thankful for every suggestion on what I am doing wrong.