Question: It should be a simple java program that a novice can create but I'm lost Problem: Farmers need to harvest their crops early enough to

 It should be a simple java program that a novice can

create but I'm lost Problem: Farmers need to harvest their crops early

enough to avoid a killing frost. For this assignment you are to

It should be a simple java program that a novice can create but I'm lost

Problem:

Farmers need to harvest their crops early enough to avoid a killing frost. For this assignment you are to write a program that reads a file created with data from the National Climatic Data Center to determine the average first day in the fall that a frost occurs. The file weatherDaily.dat contains several years of Greensboro daily weather data sorted by increasing date. Each line in the file represents one days weather and contains the values: year date of this weather record month date of this weather record from 1 to 12 day date of this weather record from 1 to 31 precipitation amount of precipitation on this day snow amount of snow that fell on this day daily high highest temperature recorded on this day in tenths of a degree Celsius daily low lowest temperature recorded on this day in tenths of a degree Celsius All values are integers. The program only requires the year, month, day and daily low, although your program must read all data values in each line.

a. [90 points] Write a program that displays the date of the first autumn frost for each year in the file. We define an autumn frost as any day when the temperature is less than zero degrees Celsius. Fall frosts occur after July. The first day of frost is when the daily low is less than zero and the month is greater than 7. After you find the first day of frost, you need to skip the rest of the days until December 31. You can use a boolean variable to indicate that a frost has already been found.

b. [10 points] Enhance your program to display the average last frost day of the year. You can use the following methods to convert the year, month and day to day of the year. Your program will also have to count the number of years in the file. You can display the average day of the year and then use that with the monthDay method to get the calendar day.

/* Day of the year for first of month */ static final int[] monthSum = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 366};

/**

* Convert year, month and day to day of the year.

* @param y year

* @param m month

* @param d day*/

static int dayOfYear( int y, int m, int d ) {

int doy = d + monthSum[m-1]; // simple day of the year

if (y % 4 == 0 && m > 2) { // if leap year and after Feb 29

doy++; // add one to day for leap day

}

return doy;

}

/**

* Convert day of the year to month / day

* @param dday day of the year */

static String monthDay( double dday ) {

int day = (int)(dday + 0.5); // round off to integer day

for (int month = 1; month

if (day

return month +"/"+ (day - monthSum[month-1]);

}

}

return "?/?";

}

Example output

First frost in 1974 was on 10/4

First frost in 1975 was on 10/31

First frost in 1976 was on 10/19

First frost in 1977 was on 10/18 . . .

First frost in 2013 was on 10/26

First frost in 2014 was on 11/3

First frost in 2015 was on 11/15

First frost in 2016 was on 11/13

Average first frost is the 307.8837209302326 day of the year

Average first frost is on 11/4

Farmers need to harvest their crops early enough to avoid a killing frost. For this assignment you are to write a program that reads a file created with data from the National Climatic Data Center to determine the average first day in the fall that a frost occurs. The file weatherDaily.dat contains several years of Greensboro daily weather data sorted by increasing date. Each line in the file represents one day's weather and contains the values: date of this weather record date of this weather record from 1 to 12 date of this weather record from 1 to 31 year month da precipitation amount of precipitation on this day snow daily high highest temperature recorded on this day in tenths of a degree Celsius daily low lowest temperature recorded on this day in tenths of a degree Celsius amount of snow that fell on this day All values are integers. The program only requires the year, month, day and daily low, although your program must read all data values in each line a. [90 points] Write a program that displays the date of the first autumn frost for each year in the file We define an autumn frost as any day when the temperature is less than zero degrees Celsius. Fall frosts occur after July. The first day of frost is when the daily low is less than zero and the month is greater than 7. After you find the first day of frost, you need to skip the rest of the days until December 31. You can use a boolean variable to indicate that a frost has already been found

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!