A good answer might be:

The answer is given below. Did you get the conditional exactly correct?

Filling in the Formula

The program with the corectly complete loop is:
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 )    
    {

      __________________

      __________________

      t = t + 1 ;
    }


  }
}

This program will give t the successive values, 0, 1, 2, ..., limit, and (limit+1). But the "gatekeeper" for the loop, the conditional, will not allow execution back into the loop body when t is (limit+1)

Now look at the formula that is to be calculated each time:

distance  =  (1/2) * G * t2
This formula will have to be translated into a Java assignment statment, which will fill the first blank. This is fairly easy, but there are two traps! The other blank will be for printing out the time and distance.

QUESTION 14:

Fill in the two blanks. Be careful with the formula. Use a tab character in the output statement.

Click Here after you have answered the question