go to previous page   go to home page   hear noise   go to next page

Answer:

A long time.


Million Dollar Program

Here is the start on a program that calculates how long it will take:

class MillionDollarYears
{
  public static void main( String[] args )
  {
    double dollars = 1000.00 ;
    final  double interest = 0.05;
    int year = ;     

    while ( dollars < 1000000.00 ) // A result-terminated loop
    {
      // add another year's interest

      dollars = ;

      year    = ;
    }

    System.out.println("It took " + year + " years to reach your goal.");
  }

}

The value of the bank account, dollars keeps building up until the goal has been reached or exceeded.


QUESTION 3:

Fill in the blanks to complete the program.