Question
In Java GUI format Objective: Write a Java program that will perform calculations on historic weather data stored in arrays This program will use temperature
In Java GUI format
Objective: Write a Java program that will perform calculations on historic weather data stored in arrays
This program will use temperature data for Somerset, Kentucky from the year 1951 to 2016. The data will be stored in two arrays, one will contain all of the years (string data), and the other will be a two dimensional array containing the high and low temperatures for the month of January for each of the years listed above.
2. The Assignment
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 JComboBox loaded with the yearTemp array to allow the user to select a year so that the program can look up the high and low temperatures for January of the selected year.
Below the user-selected year and the high and low for January of that year, display the average high and the average low for all years combined. Since this will not change with the users selection, you have options as to when you will do this calculation. You might even do this calculation before the user selects the year. You decide.
Once the user selects the year and triggers an event, the logic would be as follows:
The year the user selected would need to be looked up in the yearTemp array.
The matching index for the high and low temperatures would be accessed from the highLowTemp array.
The average daily temperature will be calculated from the high and low temperature.
The average daily temperature will be displayed along with the average for all years of high and low temperatures.
The arrays are parallel in that each year in the yearTemp array will have a matching set of high/low temperatures in the highLowTemp array. That means that the index will be the same for the year and matching high and low temperature elements. Of course, both array indexes begin with zero. |
Use an inner class for the listener. |
You may modify the arrays in this program if that will facilitate your approach. You must, however, use arrays to solve the problem
2.2. The Arrays String[] yearTemp = new { "1951", "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", "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 highLowTemp[] = new { 7, 68, 9, 77, 20, 65, -7, 63, -3, 66, 8, 62, -2, 63, 3, 58, -5, 69, 8, 70, -12, 58, -12, 71, -28, 67, -6, 66, -14, 68, -15, 62, 10, 73, 0, 64, -12, 60, -14, 66, 7, 67, -8, 71, 0, 62, 13, 69, 6, 70, -3, 57, -13, 41, -6, 60, 0, 60, 15, 56, -2, 62, -19, 62, 11, 57, -2, 61, -16, 63, -7, 62, -2, 61, 18, 67, 13, 68, 14, 62, 4, 58, 12, 67, -32, 54, 3, 69, 7, 68, -2, 68, 6, 66, 4, 73, 5, 69, 3, 61, 11, 72, -8, 57, 1, 70, 6, 69, 15, 65, 7, 67, 1, 70, 0, 60, 2, 57, 3, 62, 15, 64, 14, 68, -4, 57, 2, 59, 5, 64}; |
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