CSCI 180/181 Lab 5

handin name for today's lab is lab5 The lab is due on 19 February 2008 at 23:59. You must use good style and comments, as usual.

Objectives

In class, we looked at the WebLog-Analyzer project. We added a method to compute and return the mean of the counts: public double computeMean()


In this lab, we will add methods to the LogAnalyzer class to continue to practice with arrays. All new methods assume that analyzeHourlyData has been called prior to calling these methods.

  1. (4 points) Add a method public int [] greaterThanMean() that computes the mean of the accesses in the log and then creates an array with the hours that have access counts greater than the mean. Your array should be no bigger than needed to hold the values. The method does not have to be efficient.

  2. (3 points) Do exercise 4.52 on p. 115 and add to the class.

  3. (5 points) Do exercise 4.54 on p. 116 and add to the class.

  4. (4 points) Do exercise 4.55 on p. 116 and add to the class.

  5. (5 points) Do exercise 4.57 on p. 116 and add to the class. Call the method busiestTwoHours

  6. (4 points) Add a method called printHistogram that prints a histogram using * to show the access count graphically. Each * should represent 10 accesses. If 10 does not divide the access count evenly, add an extra * for the remainder. The histogram should have vertical bars, one per hour. You do not need to label the axes, but the bars should be printed for hours 0-23, left to right, and should be upright with the bottom of each bar lined up. Here is what the histogram should look like for the sample data. The numbers on the side are just added for reference. You do not need to include the numbers. Your solution must work for any input.

  7. (Extra credit - 3 points) Add a variation of printHistogram that takes an int size and divides the data up into ranges of hours of that size. So, if size is 4, it would print bars for 0-3, 4-7, 8-11, 12-15, 16-19, 20-23. If size does not divide the hours evenly, add 1 extra bar on the right for the extra hours.
handin the LogAnalyzer class.