For project 1, you will build a program that receives as input two files and do some processing on them.

A temperature file (e.g., temps.dat)

This file contains historic average temperatures for several locations in Texas. The data has been obtained from the United States Historic Climate Network (USCHN). Each line of the file contains a location, a date, and the average temperature (in Celsius) for that location and date. A string, corresponding to a meteorological station id, represents a location. For example, “411048” corresponds to Brenham, Texas. A date is specified by two integers: a year (for example 2016) and a month (for example 3 for March). A sample line in the temperature file would be:
410120 1893 2 6.41

The temperature value -99.99 is used by the UCHN agency to represent missing information, for example:
410120 1893 1 -99.99

Valid temperatures are assumed to be in the interval -50.0 to 50.0 (remember that they use Celsius, so this is a good range.) The first valid year is 1800. The latest valid year should be our current year. You can declare a constant in your program to specify the current year. (If we were programming this to be used for real, we would instead obtain the current year from the system, so that no code changes are required for future years.)

A query file (e.g., queries.dat)

This file contains a list of queries (i.e., requests for information) that your program should calculate based on the data in file temps.dat. Each line in the file contains one query. There are two types of queries:

AVG: given a location (specified as a station id) and a range of years (specified as two integers, for example, 2000 2006), it computes the average temperature for the location and period. If no data is available for the location/period, the answer will be the string “unknown”.

MODE: given a location and a range of years, it identifies the most common round temperature value in the period. If no data is available for the period, the expected result is the string “unknown”. Notice that the temperature values in file temps.dat are double numbers. temperatures occur the same number of times in the location/period You should round these numbers to the nearest integer before computing the mode. For example, 8.03, 8.1, and 8.5 are all rounded to 8; 8.51 and 8.8 are rounded to 9.

Your program should read these two files and generate a file results.dat with the queries and their results. 

If the temps.dat looks like this: 
411048 2015 1 9.58
411048 2015 3 14.82
411048 2016 4 20.51
411048 2016 1 10.99
411000 1973 1 0.54
411048 2016 3 18.40
411048 2016 5 -99.99

and queries.dat with:
411048 AVG 2015 2016
411138 AVG 1995 1995
411048 MODE 2015 2016

your program is expected to produce a file named “results.dat” with the following content:
411048 2015 2016 AVG 14.86
411138 1995 1995 AVG unknown
411048 2015 2016 MODE 10

Requirements