Homework 5, Ballistic Trajectory (8 points)


You are working for a defense contractor as a programmer and have been asked to write a function for use in several battlefield simulation programs. The real valued function must be named "dist" and must take two real arguments. The first argument is the angle of inclination of a cannon's barrel from horizontal, in radians. The second argument is the cannon's muzzle velocity in meters per second. The value returned by the function is the range of the cannon shell (in meters) subject to the following assumptions:

  1. Air Fiction is ignored;
  2. Length of the cannon barrel is ignored;
  3. The ground is flat over the full range of the cannon;
  4. The value of gravitational acceleration g = 9.807 m/s2.
The function will be audited by the DOD program monitor, and placed in the company software library, so must be generously commented, including a statement of the function's purpose, definitions for all variables, and a line giving your name and the creation date.

I have provided a driver program cannon.f to test your function. It reads the inclination angle in degrees, because it's easy to predict behavior for a shot straight up (90 degrees) or at 45 degrees (range about 9177 m). Add your function at the end of cannon.f, then compile and test the program.

This homework will be graded as follows:

See me or check my derivation, if you need help with your basic laws of physics.

Leave your modified version of cannon.f (don't change the file name) in your "homework" subdirectory. We will pick it up after the due date and test it.

Homework List / Home


Maintained by John Mahaffy : jhm@psu.edu