CS211 Programming Exercise 1
Spring 2005 - 75 Points

Objectives:

Due Date/Time:

This lab is due at the beginning of class Lesson 9 (Mon/Tues 31 Jan/1 Feb) A late penalty accrues at a rate of 25% for each 24-hour period (including weekends) past the on-time turn-in date and time.  The late penalty is a cap on the maximum grade that may be awarded for the late work.  Thus zero points will be awarded for a programming exercise submitted 72 hours or more late. There is no early turn-in bonus for this assignment.

Help Policy:

AUTHORIZED RESOURCES: 

      Any, except another cadet’s program.

NOTES: 

Requirements For Documentation:

Overview:

This programming exercise requires you to create a MATLAB program that determines the time and horizontal distance between the release of a gravity bomb and its impact.  Your program will get from the user the aircraft's horizontal velocity and its altitude above ground level.  Given these inputs, your program will compute and display the time and horizontal distance to impact from bomb release.  The physics and mathematics required to do this assignment are very basic.  Note that 25 of the 75 points for this assignment are based on program maintainability, independent of how your program behaves.

Ignoring wind resistance, a gravity bomb (a bomb with no guidance system) follows a ballistic trajectory given by:

x = vt

y = ½gt2

where

x is the horizontal distance from release to impact (meters)

v is the horizontal velocity (meters/second)

t is the time from release to impact (seconds)

y is the vertical distance from release to impact (meters)

g is the acceleration of gravity (meters/second2)

Since you will enter the aircraft velocity and height in English units, you will find the following conversions useful:

1 foot = 0.3048 meters

1 mile/hour = 0.447 meters/second

Since wind resistance (both horizontal and vertical components) does have an impact on falling gravity bombs, the predicted values obtained by using these equations become less accurate with increasing horizontal velocity v and vertical distance y

Specific Requirements:

  1. Read the above Help Policy carefully and ask your instructor if you have any questions.
     

  2. Create a MATLAB program named pex1 saved in the file pex1.m that:

    1. clears the command window

    2. displays a useful introduction to the program's user

    3. repeatedly prompts for and gets from the user an aircraft's horizontal velocity in miles per hour until the user enters a non-negative number

    4. displays one of the following messages based on the input aircraft horizontal velocity:

      1. if the velocity is greater than 300 MPH display:
        "WARNING: At this velocity wind resistance is not negligible.  The predicted impact distance may be high."

      2. otherwise display:
        "The velocity is in the acceptable range."
         

    5. repeatedly prompts for and gets from the user an aircraft's altitude above ground level in feet until the user enters a height between 50 and 10,000 inclusive

    6. displays one of the following messages based on the input aircraft altitude:

      1. if the altitude is less than 200 feet display:
        "WARNING: This is a very low altitude for dropping bombs!"

      2. otherwise, if the altitude is 1500 feet or higher display:
        "WARNING: At this altitude wind resistance is not negligible.  The predicted impact distance may be low."

      3. otherwise display:
        "That altitude is in the acceptable range."
         

    7. computes the time in seconds from release to impact (ignoring wind resistance)

    8. computes the horizontal distance in feet of the impact point from the release point (ignoring wind resistance)

    9. reports the predicted horizontal distance in feet (no decimal places) and time in seconds (to 1 decimal place) between release and impact
       

  3. Define all program constants at the beginning of your program.  Do not include any literal numeric values (like 9.81, 0.447, 300, 50, 1500, etc.) in your code below this section!  (You probably should have no constants other than the number 2 or 0.5 in your code.)
     

  4. Thoroughly document your code with comments including a standard program header comment block and comments in your code explaining it.  Make sure your program header includes a brief description of what your program does and a description of any help you received on the assignment in accordance with the above Help Policy.
     

  5. Use white space (space characters and blank lines) to make your code easier to read.  Ensure that your code is appropriately indented.  You can select all of your code and then press Ctrl-I for smart indent.  Avoid excessively long lines that wrap around to multiple lines in the editor.  You can use ... to continue a single statement across two lines in your m-file (as long as the break is not in a string constant).
     

  6. Select descriptive names for all of your variables and constants and ensure your are consistent in the format of your constant and variable names (e.g., first letter capitalized, underscores between words).

Turn-in Requirements:

Submit your pex1.m file including your documentation statement in the program header block.

Helpful Hints:

Grading Information:

Your instructor will grade your assignment using the following allocation of the 75 points.