A good answer might be:

Did you get the conditional exactly correct?

Filling in the Formula

The program so far:

import java.io.*;

// User picks ending value for time, t.
// The program calculates and prints the distance the brick has fallen for each t.
//
class fallingBrick
{
  public static void main (String[] args ) throws IOException
  {
    final double G = 9.80665;   // constant of gravitational acceleration
    int    t, limit;            // time in seconds, and ending value of time
    double distance;            // the distance the brick has fallen

    BufferedReader userin = new BufferedReader (new InputStreamReader(System.in));
    String inputData;

    System.out.println( "Enter limit value:" );
    inputData = userin.readLine();
    limit     = Integer.parseInt( inputData );

    // Print a table heading
    System.out.println( "seconds\tDistance"  );
    System.out.println( "-------\t--------"  );

    t  =  0 ;
    while (  t <= limit )    
    {

      __________________  // calculate distance

      __________________  // output result

      t = t + 1 ;
    }

  }
}

The loop body will execute for t = 0, 1, 2, ..., limit. At the end of the last execution, t is changed to (limit+1). But the conditional expression will not allow execution back into the loop body when t is (limit+1).

Now let us calculated the distance for each value of t:

distance = (1/2)*G*t2

Translate the formula into a Java statement to fill the first blank. Watch out: there are two traps!

QUESTION 14:

Fill in the two blanks. Use a tab character in the output statement.