A good answer might be:

  • What will be the loop control variable? The time, t, since it will be counted upward, second by second.
  • What will be inside the body of the loop? The calculation using the formula, plus a statement to change the time.

Gravity Program Skeleton

The program will look something like this:
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         = __________
    while (  ____________________ )    
    {
      (more statements will go here later.)

      t = ____________________
    }


  }
}

QUESTION 13:

For now, just think about getting the loop correct. Fill in the blanks so that the times are counted upward from zero, and that the last value printed out is when time equals limit.

Click Here after you have answered the question