Sample output from a working program is shown below.
Your program should have a function, GetIntegerArray, that takes as arguments an array and a number of values to read in, and reads in values entered by the user into the array. It also should have four separate functions that take the array and its effective size as arguments and return (1) the lowest value in the array, (2) the highest value in the array, (3) the mean, and (4) the standard deviation. In addition you should have a function, MakeHistogram, that creates the histogram array from the grade array. It should take as arguments the histogram array, the grade array and its effective size, the low and high range values (0, 100 for this problem, but write your function to work for any range) and the histogram bucket width (10 for this problem, but write your function to work for any bucket width). Finally, you should add a function PrintHistogram, that takes the histogram array and its effective size, the range values, and the bucket width, and prints the ASCII histogram to the screen.
We recommend that you implement and test this program incrementally. For example, first, implement and test GetIntegerArray, and once that works, next implement and test GetMaxValue, and so on.
To make testing easier, you can change the size of the array to something smaller like 5 or 10, and then change it to 20 later. Also, you can redirect standard input from a file that contains your input values rather than entering them by hand each time. For example, in emacs I could create a file named "testinput" with the following contents:
40 41 50 67 100 99 98 83 43 33 56 67 96 55 34 76 46 88 54 22I can then run my program and redirect stdin (use < on the command line) from testinput:
% ./a.out < testinput # the prompt output from my program would appear here # even though the input is being read from testinput rather than # from the user entering values one at a time ************ Grade Report ************* min grade: 22 max grade: 100 mean grade: 62.40 standard dev: 24.17 **************************************** 0-9 | 10-19 | 20-29 | * 30-39 | ** 40-49 | **** 50-59 | **** 60-69 | ** 70-79 | * 80-89 | ** 90-99 | *** 100 | *
Here are some sample runs of my program:
% ./a.out Enter the number of bins in the probability board> 11 Enter the number of marbles to drop> 50 Probability Board for 50 marbles and 11 bins 0 | 1 | ** 2 | ** 3 | * 4 | ************* 5 | ********** 6 | **************** 7 | **** 8 | ** 9 | 10 | % ./a.out Enter the number of bins in the probability board> 5 Enter the number of marbles to drop> 20 Probability Board for 20 marbles and 5 bins 0 | ** 1 | *** 2 | ************ 3 | ** 4 | * % ./a.out Enter the number of bins in the probability board> 5 Enter the number of marbles to drop> 20 Probability Board for 20 marbles and 5 bins 0 | ** 1 | ****** 2 | ****** 3 | ****** 4 |