Printing A Histogram

Goal: Get some practice using git (via SourceTree) and GitLab, while practicing your programming skills.

Part 1: Exercise Description

In Lesson 06 of this course you saw the exercise named Mixing Arrays and Classes: An array of simple types within a class.  In it you wrote code to print out a BarChart, which produced output that looked something like the following:

Data set 1
slot 0 contains 2
slot 1 contains 4
slot 2 contains 6
slot 3 contains 8
slot 4 contains 10 Data set 1 Bar Chart Output: ** **** ****** ******** **********

In this exercise you will revisit the earlier exercise by writing code that will produce a histogram.  While a histogram could be displayed like the horizontal bar charts we made in the previous exercise they're typically displayed vertically.  Please see the Wikipedia entry for histograms to see some examples.

For this exercise you must implement the PrintHistogram() method in the BarChart class (BarChart.PrintHistogram() ) aka so that the test code in the BarChart_Demonstration.RunExercise() method will produce the following output:

Data set 1
slot 0 contains 2
slot 1 contains 4
slot 2 contains 6
slot 3 contains 8
slot 4 contains 10
    *
    *
   **
   **
  ***
  ***
 ****
 ****
*****
*****

Data set 2
slot 0 contains 10
slot 1 contains 9
slot 2 contains 8
slot 3 contains 7
slot 4 contains 6
*
**
***
****
*****
*****
*****
*****
*****
*****

The key thing is that the 0th slot in the array will be displayed as the left-most column in the histogram.  In the top example (Data Set 1) the 0th slot contains the integer value '2' and the left-most column of the histogram has 2 stars.  In the bottom example (Data Set 2) the 0th slot contains the integer value '10' and the left-most column of the histogram has 10 stars.

Part 2: What you need to do for this exercise

  1.  Implement the PrintHistogram methods in the BarChart class, as described above
  2. You may want to run the sample code that has been provided to you, and confirm that it produces the above, example output.  You can do this by this running the code in the RunExercise method of the BarChart_Demonstration class.  
  3. Once you've successfully modified the project to acheive the above please make sure to commit your work and push (upload) your work back to the GitLab server.  When you commit that file you must use the Commit Message

    WORK_FOR_EXERCISE_5-A

    1. Please copy-and-paste the above bold, underlined message in exactly, so that I can use a script (a short program) to collect this work from you.
  4. If you used a different commit message and then later on realized your mistake, you can fix it by 'tagging' it with the above message.
    There's a detailed walkthrough here.
    Please try to EITHER use the correct commit message OR ELSE a tag - if you use both I'll ignore the older one (whichever it is)