Modify the compound-interest application of Fig. 4.6 to repeat its steps for interest rates of 5%, 6%,
Question:
Modify the compound-interest application of Fig. 4.6 to repeat its steps for interest rates of 5%, 6%, 7%, 8%, 9% and 10%. Use a for loop to vary the interest rate.
Fig. 4.6
Transcribed Image Text:
I // Fig. 4.6: Interest.java 2 // Compound-interest calculations with for.. 3 4 5 6 7 8 9 10 12 13 14 public class Interest { public static void main(String[] args) { double principal = 1000.0; // initial amount before interest double rate= 0.05; // interest rate 15 16 17 18 19 20 21 } 1 234567899 } 10 // display headers System.out.printf("%s%20s%n", "Year", "Amount on deposit"); Year Amount on deposit 1,050.00 1,102.50 1,157.63 1,215.51 1,276.28 1,340.10 1,407.10 1,477.46 // calculate amount on deposit for each of ten years for (int year = 1; year
Fantastic news! We've Found the answer you've been seeking!