I'm a student new to java and I'm having difficulty with the following problem. I have a massive String array of over 1 million weather readings, each element contains a Site ID, Site Name, Site latitude, Site Longitude, Year, Month, Date(1-31), Hour, Wind speed, Temperature.
My problem is: How many days did the temperature fall to or below 0.0 anywhere in the UK. All the entries are from the same year so that isn't a problem. But the month int variable goes ranges from 1 to 12 and the date int variable ranges from 1 to 31. What would be the best way to organise the data to allow me to only count unique days?
I've already created an object class called WeatherRecords with a get method that splits the strings up by the comma and parses each element into the correct type and stores the object in an array. Like so:
String[] weatherData = WeatherData.getData();
ArrayList<WeatherRecords> records = new ArrayList<>();
for (int i = 1; i < weatherData.length; i++) {
String line = weatherData[i];
String[] elements = line.split(",");
String siteIdString = elements[0];
String siteName = elements[1];
String siteLatString = elements[2];
String siteLonString = elements[3];
String recordYearString = elements[4];
String recordMonthString = elements[5];
String recordDateString = elements[6];
String recordHourString = elements[7];
String recordWindSpeedString = elements[8];
String recordTempString = elements[9];
int siteId = Integer.parseInt(siteIdString);
double siteLat = Double.parseDouble(siteLatString);
double siteLon = Double.parseDouble(siteLonString);
int recordYear = Integer.parseInt(recordYearString);
int recordMonth = Integer.parseInt(recordMonthString);
int recordDate = Integer.parseInt(recordDateString);
int recordHour = Integer.parseInt(recordHourString);
int recordWindSpeed = Integer.parseInt(recordWindSpeedString);
double recordTemp = Double.parseDouble(recordTempString);
WeatherRecords record = new WeatherRecords(siteId, siteName, siteLat, siteLon, recordYear, recordMonth,
recordDate, recordHour, recordWindSpeed, recordTemp);
records.add(record);
}
return records;
}