/** * Calculate compound interest. * * @author John Paxton * @version September 24, 2008 */ public class TestProgram { public static void main (String [] args) { double principal; // starting money to invest double rate; // interest rate int numberPeriods; // number of compounding periods per year int timePeriod; // number of years to compound double amount; // final amount after compounding principal = 1500.00; rate = .043; numberPeriods = 4; timePeriod = 6; amount = principal * Math.pow ((1 + rate / numberPeriods), numberPeriods * timePeriod); System.out.format("The compounded amount = $%.2f", amount); } }