Objectives

To practice functions, arrays, and iteration statements.

Overview

For this project you will implement a program that creates horizontal and vertical histograms. For example, if the user enters the values 2, 5, 6, 3, 4 and requests a horizontal histogram then your histogram will be:

* *
* * * * *
* * * * * *
* * *
* * * *

Given the same set of values, the vertical histogram will look as follows:

    *
  * *
  * *   *
  * * * *
* * * * *
* * * * *

You will implement a total of six functions whose shells you can find in the file histogram.html (to save the file right-click on the link and "Save Link As"). A description of each function is provided below.

Grading

Specifications

You are free to implement the functions in any order you want. We are describing the functions in the order we understand is best. Remember, you cannot modify the function named main.

  1. readUserValues - This function will ask the user for values, will place them in an array and then return the array. The parameter specifies the number of values to read. Use the message "Enter value" to read each value.
  2. maximumValue - This function returns the maximum value present in the array provided as a parameter. The array provided is an array of numbers.
  3. createTwoDimArray - This function creates a two dimensional array with a number of rows that corresponds to maxRows (first parameter) and a number of columns that corresponds to maxCols (second parameter).
  4. displayGraph - This function creates an html table that represents the graph.  The title parameter represents the name of the graph and the array parameter the graph to display. The array parameter represents a two-dimensional array of strings to be displayed.
  5. createArrayHorizontalGraph - This function returns a two-dimensional array of strings that represents a horizontal histogram.  The first parameter is a one-dimensional array with the values to plot and the second parameter is the symbol to use (e.g., we use '*' above) for the histogram.
  6. createArrayVerticalGraph - This function returns a two-dimensional array of strings that represents a vertical histogram.  The first parameter is a one-dimensional array with the values to plot and the second parameter is the symbol to use (e.g., we use '*' above) for the histogram.

Requirements

Web Accessibility