Description
In this assignment, you will process a file of weather forecasting data for Boulder
and answer a few questions about the weather. There is a file on moodle called
boulderData that contains comma-delimited information about the weather forecast
for each day and the next three days.
The first day in the file is January 26, 2016 and the last day in the file is September
29, 2016. The format for each line in the file is as follows:
Day Forecast
day
High
temp
Low
temp
Humidity Avg.
wind
Avg.
wind
direct.
Max.
wind
Max.
wind
direct.
Precip
1-2
6-2
016
1-26-2
016
H:4
0
L:26 43 6 WNW 10 WNW 0.0
Day: The current day
Forecast day: The day that the forecast is for. In this example, the day and forecast
day are the same, which means it’s the forecast for 1-26-2016 on 1-26-2016. There
are other lines in the file that show the forecast for a future day. For example, if the
day were 1-26-2016 and forecast day were 1-27-2016, it would be the forecast
Avg. wind: The forecasted average wind speed for the forecasted day.
Avg. wind direction: The forecasted average wind direction for the forecasted day.
Max. wind: The forecasted maximum wind speed for the forecasted day.
Max. wind direct.: The forecasted direction for the maximum wind speed for the
forecasted day.
Precip.: The forecasted precipitation.
Assignment Details
For this assignment, you need to read in the data stored in the file and store it in an
array of structs of maximum 10 elements. Your struct should have the following
minimum set of attributes:
struct Forecast{
string day;
int highTemp;
int lowTemp;
int humidity;
int avgWind;
string avgWindDir;
int maxWind;
string maxWindDir;
double precip;
};
Store only the most current forecast for each day, this would be the lines in the file
where the Day and Forecast day are the same. Discard the other lines in the file by
not reading them into your array. Your array will need to store 245 days worth of
data.
NOTE: If you’re planning to do the additional functions suggested below, After
submitting the assignment in moodle, modify your program to store all of the data
and add an additional parameter to your struct for forecast day.
Functions that need to be in your program
void populateArray(string filename,Forecast forecastData[]);
● Populates the array reading data from file called filename.
string lastDayItRained(Forecast forecastData[]);
● Returns the date of the last day it rained.
double totalRainfall(Forecast forecastData[]);
● Returns the sum of the precipitation in the data set.
CSCI 1310 – Assignment 5 Due Friday, March 3, by 08:00 am
int maxWindspeed(Forecast forecastData[]);
● Returns the index in the array where the maximum wind speed is
found.
int maxRainfall(Forecast forecastData[]);
● Returns the index in the array where the maximum precipitation is
found.
int maxTempDifference(Forecast forecastData[]);
● Returns the index in the array where with the maximum difference
between the high and low temperature.
Forecast forecastForDay(Forecast forecastData[], string day);
● Returns the forecast for a particular day in the array.
Functionality in main()
In your main() function, declare Forecast struct array and call the populateArray
function passing the filename and the struct array. Once you’re confident that the
array data is correct, call the other functions to analyze the data and print the
results. Your output should look like this:
Forecast statistics:
Last day it rained: