Homework 6: Stats Templates

Educational Objectives: After completing this assignment the student should have the following knowledge, ability, and skills:

Operational Objectives: Implement and test the function templates Mean, Median, SelectionSort, and Swap.

Deliverables: Two files: stats.t and log.txt

Assessment Rubric

================================================
item/category                       points range
-------------                       ------------
build stattest1.x - stattest11.x           0..10
stattest[1-11].x data1                     0..05
stattest[1-11].x data2                     0..05
stattest[1-11].x data3                     0..05
stattest[1-11].x data4                     0..05
student log                                0..05
templates usage                            0..05
code quality                             -50..10
dated submissions deduction [2 pts per]     ( 0)
------------------------------------------------
total                                      0..50

Note: input files may vary over time and from those distributed.

Code quality includes: 
  - conformance to assignment requirements and specifications
  - conformance to coding standards [see course organizer]
  - engineering and design, including appropriateness of name choices
  - readability
=====================================================================

Background: See lecture notes Chapter 12. Templates.

Procedural Requirements

  1. Copy the following files from the course library:

    hw6/stattest.cpp  # client program testing Stats Templates
    hw6/makefile      # builds stattest1.x, ... , stattest11.x
    hw6/hw6submit.sh  # assignment submission script
    

  2. Begin a log file named log.txt. This should be an ascii text file in cop3330/hw6 with the following header:

    log.txt # log file for stats project
    <date file created>
    <your name>
    <your CS username>
    

    This file should document all work done by date and time, including all testing and test results.

  3. Create the file stats.t defining and implementing function templates for Mean, Median, SelectionSort, and Swap. Be sure to make log entries for all work.

  4. READ the test program LIB/stattest.cpp. Note that stattest.cpp is set up so that you can choose any one of 11 different numerical types by uncommenting one of 11 possible typedef statements defining NumberType. Start your testing by creating 11 different tests stattest1.cpp, ... , stattest11.cpp, where stattestX.cpp uses the number type X.

    This is a good exercise in using basic unix commands and Emacs. Do this work yourself, on linprog. Be sure to keep your log up to date.

  5. READ the supplied LIB/makefile. Note that makefile is set up so that you can

    1. Build any specific stattestX.x target [X = 1,2,...,11]
    2. Build all stattest1.x ... stattest11.x targets
    3. Erase output data files created by runtests.sh

  6. Test your implementation using the supplied client program stattest.cpp. There should be 11 versions of stattest.cpp, one for each numerical type listed in the program header documentation, named as in the distributed makefile. Again be sure to make log entries appropriately.

  7. Turn in the files stats.t and log.txt. using the hw6submit.sh submit script.

    Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit projects. If you do not receive two confirmations, the second with the contents of your project, there has been a malfunction.

Code Requirements and Specifications

  1. In file stats.t define and implement function templates with these prototypes:

    template < typename T >
    long double Mean (const std::vector<T>& v);  // returns mean of elements of v
    
    template < typename T >
    long double Median (std::vector<T>& v);  // returns median of elements of v
    
    template < typename T >
    void SelectionSort (std::vector<T>& v);  // sorts elements of v
    
    template < typename T >
    void Swap (T& x, T& y);  // interchanges values of x and y
    

    The behavior and semantics are similar to the non-template functions from Homework 2, using vector instead of array to contain data.

  2. Be sure your code conforms to the standards in C++ Style (available also through the Course Organizer).

  3. Be sure that you have tested your code for syntax errors with the supplied test harness as well as your own test program, using the supplied makefile with warning flags set. All warnings should be eliminated.

  4. Be sure that you have tested your code for both logic errors with the supplied test harness as well as your own test program.

  5. Be sure that you have tested your code for genericity using all 11 numerical types signed char, short, int, long, unsigned char, unsigned short, unsigned int, unsigned long, float, double, and long double.

Hints