1 
 2 import javax.swing.JOptionPane;
 3 
 4 public class CDcalc {
 5 
 6     public static void main(String[] args) 
 7     {
 8         double end = 0;
 9         double interest = 0;
10         double CDValue = 0;
11         int counter = 0;
12 
13         String initialInput;  
14         initialInput = JOptionPane.showInputDialog("Enter the value of initial investment amount");
15         CDValue = Double.parseDouble(initialInput);
16         
17         String endingInput;  
18         endingInput = JOptionPane.showInputDialog("Enter the desired ending value");
19         end = Double.parseDouble(endingInput);
20         
21         String interestInput;  
22         interestInput = JOptionPane.showInputDialog("Enter the annual interest rate (%)");
23         
24         interest = Double.parseDouble(interestInput);
25 
26         while (CDValue<end)
27         {
28             CDValue = CDValue + (CDValue * interest/100);
29             counter ++;
30         }
31         System.out.println("The number of years required is " + counter);
32 
33     
34     }
35     
36 }
37