I'm trying to use a static method to find out how many years it takes to double an arbitrary amount of money so I used a dummy amount of money. The problem is, the code compiles but the code does not run properly. What am I doing wrong?
class YearsToDouble { public static void main ( String [] args ) throws Exception { System.out.println("rate(percent) years to double"); for ( int percent : new int[] {1,2,3,4,6,9,12,24} ) line(percent); } public static void line ( int percent ) { System.out.printf("%7d%17d\n",percent,yearsToDouble(percent)); } public static int yearsToDouble ( int percent ) { double balance = 1.00; int years = 0; while ( balance < 2.00) { balance += ((percent/100)*balance); years++; } return years; } }