Question
Objective: Write a Java program that will perform simple analysis on historic snowfall for Somerset, Kentucky from data stored in arrays. The data will be
Objective: Write a Java program that will perform simple analysis on historic snowfall for Somerset, Kentucky from data stored in arrays.
The data will be stored in four arrays, one will contain all of the above years (string data), the remaining three arrays will contain the snowfall data (doubles) for January, February, and March of each of the same years listed in the first array. |
2. The Assignment
2.1. Specifications
Follow this with the name of the program: guiSnowfall.
Use Good Comments
Think about the problem and decide what type each of the input numbers should be. Also, think about the calculations and decide what type the variables should be that will hold the results of the calculations.
Use camel casing for variable names, and use descriptive variable names. Do not use general variable names like "tax" or "total."
Use a drop-down box loaded with the years array to allow the user to select a year so that the program can look up the monthly snowfall amount for January, February, and March of the selected year.
The screen should display the following:
Below the drop-down box showing the user-selected year, display the snowfall for January, February, and March of that year.
Then display the total snowfall (for the three months) for the selected year.
Display the highest snowfall year of all the years (all three months combined).
Finally, display the average snowfall for all years (average of all three months combined).
Since some of these calculations will not change, regardless of which year the user selects, you have options as to when you will do those calculations. You may decide when to do those calculations.
Write methods for all tasks.
The arrays are parallel in that each year in the years array will have a matching set of snowfall amounts in the January, February, and March arrays. That means that the index will be the same for the year and matching high and low temperature elements. Of course, all array indexes begin with zero. |
Use an inner class for the listener. |
2.2. The Arrays
Copy and paste the arrays below, into your program.
String[] years = new { 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960, 1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976, 1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016 }
int snowJan[] = new { 3.9, 0.0, 0.0, 2.8, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.3, 0.0, 2.0, 0.5, 7.2, 4.5, 8.5, 6.0, 1.0, 1.3, 0.3, 1.5, 0.0, 8.0,17.5, 0.0, 3.5, 1.0, 3.0, 3.3,30.5, 0.0, 0.0, 0.0, 4.6, 0.0, 1.8, 0.0, 2.5, 2.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.7, 0.0, 7.2, 1.1, 0.2, 0.3, 5.2, 2.0, 1.2, 0.4, 0.0,11.5, 9.9 };
int snowFeb[] = new { 0.0, 0.0, 0.0, 5.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 5.3, 0.0, 2.0, 0.5, 7.2, 4.5, 8.5, 6.0, 1.0, 1.3, 0.3, 1.5, 0.0, 8.0,17.5, 0.0, 3.5, 1.0, 3.0, 3.3,30.5, 0.0, 0.0, 0.0, 4.6, 0.0, 1.8, 0.0, 2.5, 2.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.7, 0.0, 7.2, 1.1, 0.2, 0.3, 5.2, 2.0, 1.2, 0.4, 0.0,11.5, 9.9 };
int snowMar[] = new { 2.9, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 3.5, 0.0, 0.6, 0.0, 0.0, 2.0, 0.0, 0.0, 0.6, 2.0, 0.5, 0.0, 0.0, 4.0, 0.0, 0.0, 4.0, 0.0, 2.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 1.7, 3.5, 2.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.8, 0.0, 0.0, 3.2, 0.3, 0.0, 0.0, 0.0, 1.3, 3.1, 4.0, 0.0 };
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started