public class Finance { public static double interest(int years, double start, double rate) { return start * Math.pow(1 + rate / 100.0, years); } public static double payment(int years, double start, double rate) { return start * (rate/100.0)/(1.0 - Math.pow(1 + rate/100.0, -years)); } public static void main(String [] args) { // test the interest method. System.out.printf("Test the interest() method.\n"); for (int i = 1; i <= 20; ++i) { double money = interest(i, 1000, 5); System.out.printf("%.2f\n", money); } // test the payment method. System.out.printf("Test the payment method.\n"); for (int amount = 50000; amount < 500000; amount += 50000) { double pmt = payment(30, amount, 5); System.out.printf("%.2f\n", pmt); } } }