IUP Computer Science
COSC 110   Fall 05

Project #6
(Canadian Weather)
(Due 9 Dec 05)

Every day in New Brunswick, the weather reporting stations send information to the Provincial Weather Center, in Saint John.  At the center, some simple data processing is done on the stations' data to produce a report about the weather for the day.  The data reported from each station consists of the number of hours of sunshine for the day (to the nearest tenth of an hour) and the temperature at each hour of the day (starting at midnight, 00:00, and ending at 11 pm, 23:00).  The temperatures are reported in oC to the nearest tenth of a degree.  Each day the data is collected into a file that has the same form.  Here are the first few lines from the file for September 15, 2005.  It indicates that there are 97 reporting stations.  the next line is from station 1138; it indicates 2.1 hours of sunshine; this is followed by 24 hourly temperatures.  The next line is for station 1142 and has similar information.  Not every station makes a report every day.

97
1138  2.1   6.3  6.5  5.0  2.4  2.2 -1.7  0.8  4.7  5.8  8.3  9.1  and-13-more
1142  2.0   6.5  4.9  3.9  0.8  1.3 -2.5  3.3  6.3  5.7  9.3  8.3  and-13-more
1146  2.7   6.7  6.3  3.3  3.9  2.5 -0.5  2.7  4.5  8.6  8.0 11.7  and-13-more
1148  4.2   4.4  4.4 -0.1 -0.1 -2.5 -5.1 -3.2  0.6  1.9  4.5  6.9  and-13-more

You are to write a program to produce the report that the Weather Center needs.  The report requires that your program output the following information to a file.

  1. The province-wide average number of hours of sunshine and the province-wide average temperature for the entire day (produced by averaging the temperatures from all stations and all hours together).  Use 3 decimal places for these averages.  Also show the number of stations reporting for the day.
  2. For each station, output the station number, the hours of sunshine, a + or - to indicate that these hours are above or below the average, the station average temperature for the day, and a + or - to indicate that this station average is above or below the province-wide average.  Use 3 decimal places for the average temperatures.
  3. For each hour of the day, output the number of the station with the lowest temperature and what that temperature was and the number of the station with the highest temperature and what that temperature was.
Here is a partial display for September 15.

New Brunswick report for file 05sep15.txt
Province Averages:  Sunshine 3.652  Temperature 5.834 for 97 Stations

Station  Sunshine  AverageTemp
   1138      2.1-       7.563+
   1142      2.0-       7.513+
   1146      2.7-       8.383+
   1148      4.2+       4.417-
    .         .            .

Hour    Min Station      Max Station   Temperature Gap
   0    0.3    1567      9.2    1964          -        +
   1   -0.6    1704      8.6    1199         -        +
   2   -1.6    1432      6.5    1374        -       +
   3   -3.6    1383      5.2    1964      -        +
   4   -5.3    1399      3.4    1964    -        +
   5   -6.7    1507      1.7    1251   -       +
   6   -4.6    1343      4.3    1964     -        +
   .     .       .        .       .

Sunshine/Temperature Correlation Coefficient: -0.052
Stations with both Hourly Max and Min:  None

Your program must be designed to prompt for and read in the name of the data file, then read the data in that file to produce the report.  The report is not to be displayed on the screen.  Instead, the program must prompt for and read in the name of the file where it will write the report, then write the report there.  Data files named  05sep15.txt, and 05sep16.txt are available on the I: drive at I:\jlwolfe\110 and P: drive at P:\courses\fall2005\COSC\COSC110\xxx\information (where xxx is the section number) for you to test your program on.  The files 15report.txt and 16report.txt are available to show you the results you should be getting on this data.  Two days before the project is due, I will make available other files that I want you to use as data when you hand in your program.

Hand in a Visual Studio printout of your well-documented program and printouts of the report files from the data files that I provide just before the due date.  Also, copy your .cpp file to the P: drive, handin folder after naming it after yourself.

EXTRA CREDIT:

You might have noticed that the sample report above has elements that are not required.  If you include these elements in your program's reports, you can get extra credit.  There are three options; you may do any or all.  The greater the difficulty, the more the option is worth.

  1. Rough Correlation Coefficient:  For each weather station, determine whether the sunshine for the day is above (+1) or below (-1) the province-wide average, call this the sun factor.  Determine whether the average temperature for the station is above (+1) or below (-1) the province-wide average, call this the temperature factor.  For each day, multiply the sun factor times the temperature factor and add up these products.  Dividing this by the number of stations gives the rough correlation coefficient.  [Easy]
  2. Temperature Gap:  For each hour of the day, make a small graphic representation of the highest and lowest temperatures in the province.  Mark the lowest with a minus sign, the highest with a plus sign.  The graph should be to scale and should fit to the right of the hourly highs and lows table.  In the example, I scaled horizontally so that each character position is 1.0 degrees.  [Medium]
  3. From among the stations that have the highest and lowest hourly temperatures, determine if any of these stations had both a highest and a lowest for the day (obviously at different hours).  Display the station numbers of these (or "None" if there aren't any).  [Hard]