CS211 Programming Exercise 3
Spring 2008 - 100 Points
Due: Lesson 30 (Thurs/Fri, 10/11 Apr 2008 )

Objectives:

Due Date/Time: 

This lab is due at the beginning of class on Lesson 30 (Thursday/Friday, April 10/11) 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:

Problem Overview:

The biggest change to the Air Force lifestyle in 2004 was the introduction of the new Fit To Fight fitness program.  This program requires all airmen to exercise regularly and sets high standards for fitness testing.  The Fit to Fight program requirements and fitness assessment score charts are described in AFI 10-248 which became effective on 1 January 2004.  The new fitness assessment includes 4 components: a 1.5 mile run, sit ups, push ups, and measurement of an individual's abdominal circumference.  Based on an airman's sex, age, and performance in each of these areas, they receive a composite fitness score of up to 100 points.  Based on their composite score, an airman is assigned a fitness level as shown below.

composite score fitness level
< 70 poor
70 - 74.99 marginal
75-89.99 good
≥ 90 excellent

Airmen that score at the good or excellent fitness levels test once per year.  Airmen that score at the marginal or poor fitness levels must test more often and take measures to improve their fitness level. 

For programming exercise 3 you will write a MATLAB program that reads in a file containing actual 2004 results from the Air Force fitness program and then allows the user to display information about the input data.

A fitness data file is a text file named Fitness_Data*.txt, in which the * represents zero or more valid file name characters.   Each row in a fitness data file consists of one test record.  Each test record has 12 data fields which represent the airman's:

  1. age

  2. gender (M = male, F = female)

  3. abdominal circumference (to nearest half inch)

  4. abdominal circumference points (0-30)

  5. run time in seconds

  6. run time (aerobic component) points (0-50)

  7. number of pushups completed in 1 minute

  8. pushup points (0-10)

  9. number of crunches completed in 1 minute

  10. crunch points (0-10)

  11. composite score (0-100)

  12. fitness level (poor, marginal, good, or excellent)

Look at Fitness_Data_10.txt for an example of a fitness data file with just 10 records.

Your program will input data from all records in a user-selected fitness data file, store the input data in a single structure array, and then allow the user to repeatedly select one of the following ten data display options:

  1. a pie chart showing the percentages of male and female records

  2. a histogram showing the combined (male and female) distribution of ages

  3. a pie chart showing the percentages of males with poor, marginal, good and excellent fitness levels

  4. a pie chart showing the percentages of females with poor, marginal, good and excellent fitness levels

  5. a pie chart showing the percentages of all airmen with poor, marginal, good and excellent fitness levels

  6. a histogram showing the combined (male and female) distribution of composite fitness scores in the data file

  7. a bar chart showing the average pushups for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46

  8. a bar chart showing the average crunches for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46

  9. a bar chart showing the average run times for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46

  10. a bar chart showing the average abdominal circumferences for males and females in 4 age groups: <=25, 26-35, 36-45, and >=46

While there are 10 different display options, there are only 4 substantially different types display options: 1, 2&6, 3-5, and 7-10.

To gain a good understanding of how your program should behave, run pex3p.p on the fitness data test files linked below.

Specific Requirements:

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

  2. Create a MATLAB program named pex3 saved in the file pex3.m that consists of a main program (function pex3) and internal functions that do most of the work.
     

  3. Develop your main program (function pex3) code in conjunction with developing and testing internal functions that carry out most of the work.  Your main program code may display the option menu and repeatedly call functions based on the user-selection option.  Your main program may not include functions that directly input or display data. 
     

  4. Declare a single global variable that will hold all input data in a structure array.  Most of your internal functions will need to use this global variable.  It is appropriate to use a global variable in this case because for large input files the structure array will be very large and would be very inefficient to pass as a function argument.  Also, if your name your global structure array Fitness_data, begin your pex3 function with the command:

    clear global Fitness_data

    Since global variables are persistent (they continue to exist after a function like pex3 completes), this command is useful for deleting any old copies of your global structure array created by prior runs of your program.  Failing to use this command could result in difficult to find errors.
     

  5. Add code (in pex3 and internal functions) to do the following:
    1. clear the command window and then display your name and a program introduction

    2. wait for the user to press enter (finish reading the introduction) before proceeding

    3. get from the user the name of a fitness data file using the uigetfile dialog box, by default the user should be limited to file names of the form Fitness_Data*.txt

    4. read in data you will need from all records in the user-selected data file and store them in a single structure array

    5. repeat the following until the user selects the exit option

      1. display a menu of display options using the listdlg dialog box

      2. get from the user a single display option (one of the ten listed above) or the exit option

      3. display a pie chart, histogram, or bar chart based on the user-selected option

      4. using the waitforbuttonpress function, close the displayed figure when the user clicks on it
         

  6. Thoroughly document your code with comments including a standard program header comment block, comment header blocks describing each function, 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.
     

  7. Use descriptive names for all of your variables, constants, functions, and dummy arguments.  Make sure you are consistent in the format of all your names.
     

  8. Make sure all of your code is properly indented.  You can select all of your code and then use Smart Indent (CTRL-I) to properly indent all of your code.

Turn-in Requirements:

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

Helpful Hints:

Grading Information:

Proper Documentation Statement (-5 pts)?                               

Criteria

Pts

Good programming practice and design

30

Standard header comment block for the file with all elements appropriately filled in

5

Header comment block for each function with all elements appropriately filled in

5

Appropriate commenting in the program body (section comments, variable descriptions)

5

Meaningful and consistently formatted variable names

5

Easy-to-read program formatting (appropriate use of spaces within lines, similar statements grouped and separated with a blank line)

5

The code is grouped into appropriate sub-functions with appropriate arguments passed

5

Program correctness

70

Appropriate Program Introduction 5
Reading required data from an input file 7
Storing all input data in a single global structure arraay 3
Getting the user option with appropriately configured list dialog box 10
Correct implementation of options 45

Totals

100

Late Penalties (-25, -50, -75 -100)