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
- (30 pts) Horizontal Histogram Creation
- (30 pts) Vertical Histogram
- (30 pts) Functions Requirement
- (5 pts) Good Indentation
- (5 pts) Good Variable Names
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.
- 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.
- maximumValue - This function returns the maximum value
present in the array provided as a parameter. The array provided is an
array of numbers.
- 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).
- 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.
- 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.
- 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
- As with all programming assignments:
- You must use meaningful variable names.
- You must use good indentation
- You cannot use any of the String functions (e.g., join, sort, toString,
etc.). If you have any questions about using a particular function let us
know.
- You may not add or remove any parameters from the functions specified
above.
- You must use the functions you are defining in your program.
- You cannot modify the function named main.
- You may not define any other function besides the functions described
above.
- You must verify your program works for different sets of values (not
just the ones provided above).
- You must use for loop(s).
- You must work on this project by yourself.