import javax.swing.JOptionPane; public class ExamplePage17 { public static void main(String[] args) { double balance = 10000.0; //Current balance (amount) double interest; //Interest amount each year int years = 0; //#years to $20,000.00 while ( balance < 20000.0 ) { years = years + 1; //Count another year interest = balance * 0.05; //Figure the interest amount balance = balance + interest; //Update current balance } //System.out.println("It took " + years + " years at 5% to double $10,000"); String info = "It took " + years + " years at 5% to double $10,000"; JOptionPane.showMessageDialog(null, info); } }