import java.util.Scanner; /** * Write a description of class TestProgram here. * * @author John Paxton * @version September 26, 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 Scanner inputSource = new Scanner (System.in); System.out.println("Compound Interest Calculator"); System.out.println("----------------------------"); System.out.print("Enter the starting principal: "); principal = inputSource.nextDouble(); System.out.print("Enter the interest rate percent (e.g. 4.3): "); rate = inputSource.nextDouble(); rate = rate / 100; System.out.print("Enter the number of compounding periods: "); numberPeriods = inputSource.nextInt(); System.out.print("Enter the number of years to compound: "); timePeriod = inputSource.nextInt(); amount = principal * Math.pow ((1 + rate / numberPeriods), numberPeriods * timePeriod); System.out.format("The compounded amount = $%.2f", amount); } }