Numeric Array - Frequency of numbers and Frequent Mode(2002)
Your computer science teacher is trying to analyze the performance of the class in the previous exam. He has a class called Performance, which contains the marks of 600 students in the class. These are not sorted. He wants to find two quantities:
mode - the most frequently occurring mark in the class. If two or more marks occur equally frequently then the highest of these marks is the mode
mode frequency - frequency at mode
You can make the following assumptions:
the class has 600 students
the maximum marks anyone can get are 100 and the minimum is 0
all student marks are whole numbers
Important: You are not allowed to sort the marks.
Some of the member functions/methods of Performance are given below:
Class name : Performance
Data members/instance variables:
mark[ ] : an integer array to store the marks of 600 students
mode : to store the mode
freqatmode : to store the frequency at mode
Member functions/methods:
Performance( ) : constructor
void readmarks( ) : for reading the marks into the array
int getmode( ) : for returning the mode
int getfreqatmode( ) : for returning the frequency at mode
void calcmodeandfrequency( )
: a single function that calculates both mode and frequency at mode
(a) Specify the class Performance giving the details of the constructor, int getmode(),
int getfreqatmode(), void calcmodeandfrequency() only. You may assume that
the other functions are written for you. You do not need to write the main function.
(b) What care do you need to take while designing void calcmodefrequency()?