I've just started learning Java/BlueJ at uni, and I need a bit of help
with one of my assignments.
The assignment is to store the maximum hourly temperatures for each
day of a week from the text file weektemp.txt.
Manipulate the stored data to:
- find the hottest and coldest hours
- average daily temperature
- temperature for a specific hour
and
- the daily temperature range.
Part A:
Do the above using an array of arrays.
Part B:
Do the above using an array of Day objects.
I didn't have a problem with part A, or the manipulation of the data;
I dimensioned my array as:
double[][]weekTemps = new double[7][24];
read the data file with BufferedReader, tokenized the string and
placed each token into its appropriate array element.
And this all worked fine.
However with part B I can create the array Week of Day objects (which
also contains a array of doubles called Hours).
My problem is that I can't seem to work out how to read the data from
the text file into this new array of Hours inside the array of Day
objects.
My array of Day object looks like this:
Day[] days = new Day[12];
days[0] = new Day(24);
days[1] = new Day(24);
days[2] = new Day(24);
days[3] = new Day(24);
days[4] = new Day(24);
days[5] = new Day(24);
days[6] = new Day(24);
and in my Day object:
double[] hours = new double[24];
I tried reading a line at a time and sending each new line to a new
Day object to be tokenized there, however this didn't work properly
and on asking my lecturer he aid he didn't want it done that way anyway.
Could someone pleeeeeease help me as this is driving me nuts.