Please send questions to st10@humboldt.edu .

// Contract: show_grade_freq: int[] int -> void
// Purpose: print to the screen the numbers of A's, B's,
//          C's, D's, F's, and "illegal" grades found in
//          <letter_freqs>, which contains <num_letters>
//          elements.
//
// Examples: If int num_letts[6] = {3, 4, 1, 1, 1, 2},
//          then show_grade_freq(num_letts, 6) would cause the
//          following to be printed to the screen:
// number of A's:  3
// number of B's:  4
// number of C's:  1
// number of D's:  1
// number of F's:  1
// number illegal: 2
//
// by: Sharon M. Tuttle
// last modified: 12-02-05

#include <iostream>
using namespace std;

void show_grade_freq(int letter_freqs[], int num_letters)
{
    const int NUM_KINDS = 5;
    char letter_name[NUM_KINDS] = {'A', 'B', 'C', 'D', 'F'};

    // warn if some letter_freqs values are about to be ignored
    //     (if there are too many...!)
    if (num_letters > NUM_KINDS+1)
    {
        cout << "WARNING: note that elements " << NUM_KINDS
             << " through " << num_letters-1 << "are being ignored."
             << endl;
    }

    for (int i=0; i < NUM_KINDS; i++)
    {
        // show how many of this grade there are
        cout << "number of " << letter_name[i] << "'s: "
             << letter_freqs[i] << endl;
    }
    cout << "number of bad entries: " << letter_freqs[NUM_KINDS]
         << endl;
}