
public class Interest2 {
       
       /*
          This class implements a simple program that
          will compute the amount of interest that is
          earned on $17,000 invested at an interest
          rate of 0.07 for 5 years.  The value of
          the investment at the end of each year
          is printed to standard output.
       */
    
       public static void main(String[] args) {
       
           double principal = 17000;  // the initial value of the investment
           double rate = 0.07;        // the annual interest rate
           
           int years = 0;  // counts the number of years that have passed
           
           while (years < 5) {
              double interest = principal * rate;   // compute this year's interest
              principal = principal + interest;     // add it to principal
              years = years + 1;    // count the current year.
              System.out.print("The value of the investment after ");
              System.out.print(years);
              System.out.print(" years is $");
              System.out.println(principal);
           } // end of while loop
                          
       } // end of main()

} // end of class Interest2
