void GradeDistribution(istream & input, Grade & grades) // precondition: input is open for reading // grades.freq.length() >= 4 // postcondition: grades.freq contains the frequency count of // each grade in input, // grades.count contains the total number of grades // in input { int k,index; char ch; for(k=0; k < 4; k++) { grades.freq[k] = 0; } while (input >> ch) { index = ch - 'A'; // map to 0, 1, 2, 3 grades.freq[index]++; // bump # occurrences grades.count++; // bump total count } }