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

Answer:

It is not a sentinel controlled loop because no data is read in and checked for a sentinel.


The Gloomy News

How many years does it take to reach a million dollars? 142

It might be that you do not wish to wait that long. After examining your lifestyle, you decide to give up your expensive chocolate-chip cookie habit.

Now you can put an extra $1000 into your bank account at the end of every year. Now how long will it take to reach your million dollar goal?


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

    while ( dollars < 1000000.00 )
    {
      // add another year's interest
      dollars =  dollars + dollars*0.05 ; 

      // add in this year's contribution
       ;

      year    =  year + 1 ;
    }

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

}


QUESTION 5:

Fill in the bank.... err, blank.