Date: Mon, 11 Nov 1996 17:12:10 GMT Server: NCSA/1.5 Content-type: text/html Last-modified: Wed, 06 Nov 1996 18:32:19 GMT Content-length: 3671 Quiz 4 - CS 302 Fall 1996 - Section 4

CS 302 Fall 1996 - Section 4

Quiz 4 (Take Home)

Due Monday, November 11, 1996


This quiz is a ``take home'' assignment that counts the same as an in-class quiz. Like an in-class quiz, this should be all of your own work, though you are welcome to use your text and/or a computer to assist you in this assignment. Your answers may be written out by hand, or preferably, typed.
  1. (5 points) Write a function called display that takes two parameters: an array of characters and an integer for size of the array. The function should write the first N characters of the array to cout, where N is the size parameter that was passed into the function. (Precondition: The size passed in will not be longer than the actual size of the array.)

  2. (5 points) Write a function called num_equal that takes three parameters: two arrays of integers and an integer variable for the number of valid entries in the array (in most cases just the size of the array). The function should return the number of pairs of integers that are the same. For example, if the function was passed two arrays {1, 2, 3, 4} and {2, 2, 3, 5}, and size 4, the function would return 2. (Precondition: The size passed in will not be longer than the actual size of either array.)

  3. (8 points) Design and implement a QuizScores class. This class will be used to read in and average quiz scores. All quiz scores are integers from the range 0-20. You will need the following private variables: You will need the following public methods:

  4. (2 points) Modify your QuizScores class by adding another public method that will produce a histogram of the results. The method should take a single ofstream as a parameter and write to that stream a histogram of the quiz results. To do this you will need a local array variable with 21 elements (0-20 is 21 possible scores). Use this array to count how many time each score occurs in the file. For example, if the quiz scores were 10, 15, 15, 15, 15, 18, 18, 20, the following should be displayed:
     0: 
     1:
     2:
     3:
     4:
     5:
     6:
     7:
     8:
     9:
    10:*
    11:
    12:
    13:
    14:
    15:****
    16:
    17:
    18:**
    19:
    20:*
    
    (Note: This question is only two points due to the extra time it will take to complete, if you can not finish this or can't figure it out, the most you can lose on this problem is only two points.)