Question: 1. Modify the compound-interest application in interest.java (available on Blackboard) to repeat its steps for interest rates of 5%, 6%, 7%, 8%, 9% and 10%.

1. Modify the compound-interest application in interest.java (available on Blackboard) to repeat its steps for interest rates of 5%, 6%, 7%, 8%, 9% and 10%. Use a for loop to vary the interest rate.

interest.java :

// Compound-interest calculations with for. public class Interest { public static void main(String[] args) { double principal = 1000.0; // initial amount before interest double rate = 0.05; // interest rate // display headers System.out.printf("%s%20s%n", "Year", "Amount on deposit"); // calculate amount on deposit for each of ten years for (int year = 1; year <= 10; ++year) { // calculate new amount on deposit for specified year double amount = principal * Math.pow(1.0 + rate, year); // display the year and the amount System.out.printf("%4d%,20.2f%n", year, amount); } } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!