CSC 222: Object-Oriented Programming
Fall 2015

HW 5: Arrays and Data Structures

As an in-class exercise, you designed and implemented a UFOsighting class that could be used to store and access data about a UFO sighting. You then took the UFOlookup class and added functionality in order to filter out sightings from a particular state or from within a range of dates.

For this (relatively) short assignment, you will add one additional feature to the UFOlookup class, the ability to compare the number of sightings from different states.

    /**
     * Compares UFO sightings from different states over the specified range of dates, 
     * displaying the counts and percentages for each state, as well as a crude histogram.
     *   @param startDate the starting date of the range, e.g., "2005/04/01"
     *   @param endDate the ending date of the range, e.g., "2005/04/05"
     *   @param states a sequence of state abbreviations, e.g., "NE IA MO"
     */
    public void compareStates(String startDate, String endDate, String states)  

For 60% credit: your method should process all of the states in the third parameter and display the number of sightings that occured in those states within the specified dates. For example, assuming that fooFighter is a UFOlookup object initialized with file "ufo.txt", then the call fooFighter.compareStates("2005/04/01", "2005/04/30", "NE IA MO KS SD CO") would produce the following output:

	172 sightings between 2000/01/01 and 2000/12/31:
	NE 12
	IA 28
	MO 53
	KS 25
	CO 43
	WY 6
	SD 5  

For 80% credit: your method should also calculate and display the percentage of sightings for each state, rounded to the nearest integer. It should also display a simple histogram, where the number of asterisks corresponds to the percentage. For example,

	172 sightings between 2000/01/01 and 2000/12/31:
	NE ******* 12 (7%)
	IA **************** 28 (16%)
	MO ******************************* 53 (31%)
	KS *************** 25 (15%)
	CO ************************* 43 (25%)
	WY *** 6 (3%)
	SD *** 5 (3%)

For 100% credit: your method should display the data ordered by the counts. That is, the state with the highest number of sightings should be displayed first, then the next highest state, and so on. For example:

	172 sightings between 2000/01/01 and 2000/12/31:
	MO ******************************* 53 (31%)
	CO ************************* 43 (25%)
	IA **************** 28 (16%)
	KS *************** 25 (15%)
	NE ******* 12 (7%)
	WY *** 6 (3%)
	SD *** 5 (3%)

Helpful Hints