Most spreadsheets provide the ability to make a graph of a series of numbers, or a series of x-y coordinates, in a variety of formats, but not all will plot a histogram:

The purpose of this assignment is to calculate the values needed to plot a histogram. Your program should read a sequence of numbers from a file called "numfile", one to a line. It should print how many values were read and the minimum and maximum of the values, and ask the user how many bars the histogram should have. (If the user enters a number smaller than 2 it should print an error message and try again until it gets a valid number. If the number is larger than the number of data points it should just print a warning and proceed.) It should then divide the range between the maximum and the minimum into that many intervals and count how many values fall into each interval. Finally, it should write the results into a new file called "histfile". Each line of this file should have two numbers separated by a comma:
xxx,yyy
where xxx is the midpoint of an interval and yyy is the number of data points that fell into the interval.
To open numfile for reading:
open INFILE, "<numfile";
and to open histfile for writing:
open OUTFILE, ">histfile";
where INFILE and OUTFILE are file handle names of your choosing. Open is a function that returns a Boolean value, true for success and false for error, so you can use this return value for error checking. To read the lines of numfile:
while ( <INFILE> ) {
chomp;
$line = $_;
...
}
Submit your well-documented program online using the command
provide comp14 hw5 progname.pl
The documentation should contain your name near the top. The assignment is worth 100 points. Style (good variable names, comments, indentation, etc.) will count for 20 points and error checking will count for 10.