1. Prompt the user for the amount of an initial investment, the number of years, and the range of interest rates. Then print a table of the value of an initial investment over the range of years at the range of interest rates. The table should look similar to the following for an initial investment of $1000, invested for 5 years.

1. Years

a. 1 2 3 4 5

ii. Interest Rate

iii. 5% $1051 $1105 $1161 $1221 $1284

iv. 6% $1061 $1127 $1197 $1271 $1349

v. 7% $1072 $1150 $1233 $1323 $1419

vi. 8% $1083 $1173 $1271 $1377 $1491

vii. 9% $1094 $1197 $1309 $1433 $1568

Remember that you should calculate the value of the investment compounded daily for 1 year. So for 365 days, we will multiply the current value of the investment by the interest rate / 365 and add that back into the value of investment. You will need to use nested loops to build the table.

1. Years

a. 1 2 3 4 5

ii. Interest Rate

iii. 5% $1051 $1105 $1161 $1221 $1284

iv. 6% $1061 $1127 $1197 $1271 $1349

v. 7% $1072 $1150 $1233 $1323 $1419

vi. 8% $1083 $1173 $1271 $1377 $1491

vii. 9% $1094 $1197 $1309 $1433 $1568

Remember that you should calculate the value of the investment compounded daily for 1 year. So for 365 days, we will multiply the current value of the investment by the interest rate / 365 and add that back into the value of investment. You will need to use nested loops to build the table.

Here is the code I have so far:

import java.util.Scanner; public class Multitable { public static void main (String Args []) { double r; int n; int k; double rate1; double rate2; int years; double value; double newrate; double val; double compound; double sum; Scanner in = new Scanner (System.in); System.out.print("Please enter a starting value ($):"); value=in.nextDouble(); System.out.print("Please enter a starting rate (%):"); rate1=in.nextDouble(); System.out.print("Please enter an ending rate(%):"); rate2= in.nextDouble(); System.out.print("Please enter the number of years:"); years = in.nextInt(); for (int l=1; l<=years; l++) { System.out.print("\t "+l+" "); value = value; } System.out.println(); for (int l=1; l<=years; l++) { rate1 = rate1; rate2 = rate2; for (r=rate1; r<=rate2; r++) { if (r<10) System.out.print(" "+r+"%"+" "); if (r>=10) System.out.print(r+"%"+" "); newrate = r/100.0/365.0; for (k = 1; k<=365; k++) { value = value*newrate+value; } System.out.printf("%.0f ", value); System.out.println(); } } } }

Basically, it compiles,and it does a calculation - but I am having a couple problems. I have been testing the formatting of the table, and I've been getting this: (when I test the rate of 5%)

--------------------Configuration: Multitable - JDK version 1.6.0_17 <Default> - <Default>--------------------

Please enter a starting value ($):1000

Please enter a starting rate (%):5

Please enter an ending rate(%):5

Please enter the number of years:5

1 2 3 4 5

5.0% 1051

5.0% 1105

5.0% 1162

5.0% 1221

5.0% 1284

Process completed.

The values are right (save the third one,but that's a rounding error?)

But I can't manage to get it to go in a line across the top...and when I do attempt that, I get the line, but everything has 5.0% next to it.

Also, when I test for more rates, the values get messed up. I don't really know how to rest my variable each time I go through....I need to reset value to the user entered value every time the program starts over for a new rate? How do I do that? It's annoying though, because even my first values get messed up (for 5%) when they work on their own.

--------------------Configuration: Multitable - JDK version 1.6.0_17 <Default> - <Default>--------------------

Please enter a starting value ($):1000

Please enter a starting rate (%):5

Please enter an ending rate(%):6

Please enter the number of years:5

1 2 3 4 5

5.0% 1051

6.0% 1116

5.0% 1173

6.0% 1246

5.0% 1310

6.0% 1391

5.0% 1462

6.0% 1553

5.0% 1632

6.0% 1733

Process completed.

Can anyone help me? Please?!