public class Invest { public static void main(String[] args) { ConsoleReader console = new ConsoleReader(System.in); System.out.println("Interest rate: "); double rate = console.readDouble(); final double INITIAL_BALANCE = 10000; final int NYEARS = 20; double balance = INITIAL_BALANCE; // accumulate interest for NYEARS for (int year = 1; year <= NYEARS; year++) { double interest = balance * rate / 100; balance = balance + interest; System.out.println("year: " + year + " balance: " + balance); } } }