CMSC 160 -- Lab 8

Lab 8

Getting Started

Log into the computer science server and use wget and tar to download your starter code.
  1. Use wget to download the file at http://cs.longwood.edu/courses/cmsc160/f17/files/lab8.tgz
  2. Uncompress the lab8.tgz file by using tar -xvzf lab8.tgz
  3. Use ls to see that there is a new directory called lab8
  4. Use cd lab8 to change directory to the lab8 directory


The Problem

In this lab we will:
  1. use random data to test our program
  2. use if statements
  3. use functions
  4. use loops
  5. use vectors
In this lab we will use vectors to generate some statistics. You will read in an integer for the size of the vector and fill your vector with random integers. You are to write the following functions:
    1. mean
      input: a vector of ints
      output: the average of the integers in the vector
      
    2. almostMedian
      input: a vector of ints
      output: the integer which is the median of the vector (if there are an even number of
       integers choose one of the two "in the middle")
      
    3. count
      input: a vector of ints, an integer num
      output: the number of times that num occurs in the vector
      
    4. almostMode
      input: a vector of ints
      output: the most frequently occuring integer (if there is a tie choose one of the numbers)
      

    Remember, you will be graded on style, syntax, functionality, and correctness. REMEMBER to submit a readme.txt file.

    Handin

    When you are done you may hand in your lab by using make handin.

    The lab is due at 11:59pm Oct. 17th 2017.