Write a Graph class that has methods countIt and graphIt. countIt should use five counters (c0, c1, c2, c3, and c4) to count the number of 0s, 1s, 2s, 3s, and 4s it is passed. Use a single simple statement (not an if statement) that increments one of the slots of a counter array c. The c array should have five slots, each slot serving as one counter. For example, c[0] should count the number of 0s, etc. Design your program so that it can be modifed to handle a different number of counts with almost no changes. graphIt should display the final counts in the form of a bar graph.
Please help me out this is so hard!
Break the problem down, then break it down again. Keep going until you can code each section in about 10-15 lines of code. I've also taken the problem description and used each sentence of it as a comment for a function. One advantage that you have, the values that you're counting make great indexes into your array, so you could write something like: c[number]++;
Join our real-time social learning platform and learn together with your friends!