For this assignment, you need to submit three files: WeatherForecaster.hpp….solved

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

For this assignment, you need to submit three files: WeatherForecaster.hpp,
WeatherForecaster.cpp, and main.cpp. The files should be zipped to create on .zip
file called Assignment6_LastName, where LastName is your last name. Please
include comments in your code that explain what your code is doing. The comments
should also include your name, recitation TA, and the assignment number.
Weather forecasting
Objectives:
1. Apply the concept of program decomposition.
2. Define a class managing multiple files for the header, methods and driver.
3. Apply the concept of private vs public variables and functions.
This assignment builds on the previous assignment by incorporating classes into
your program. The data file you will use is the same, it’s the boulderData file on
Moodle. If you downloaded that file and changed its format for Assignment 5, you
are welcome to use your same file for this assignment.
The boulderData file contains comma-delimited information about the weather
forecast for the current 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 Forecas
t day
High
temp
Low
temp
Humidit
y
Avg.
wind
Avg.
wind
direct
.
Max.
wind
Max.
wind
direct
.
Preci
p
1-26
-201
6
1-26-20
16 H:40 L:26 43 6 WNW 10 WNW 0.0
High temp: The forecasted high temp for the forecast day.
Low temp: The forecasted low temp for the forecast day.
Humidity: The forecasted humidity for the forecast day.
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
There is a .hpp file on Moodle that provides a definition for a WeatherForecaster
class. The functionality for that class is similar to the functionality you implemented
in Assignment 5, with a few additional functions. Instead of using an array of structs
and functions to process the array, you will create one WeatherForecaster object
that includes the array of structs as a private variable and public methods to process
the data.
The struct for this assignment has an additional member called forecastDay, you will
need to store all of the data this time.
struct ForecastDay{
string day;
string forecastDay;
int highTemp;
int lowTemp;
int humidity;
int avgWind;
string avgWindDir;
int maxWind;
string maxWindDir;
double precip;
};
CSCI 1310 – Assignment 6 Due Saturday, Mar 10, by 08:00 am
Methods in the WeatherForecaster class
void addDayToData(ForecastDay);
● Takes a ForecastDay as an argument and adds it to the private array
stored in the WeatherForecaster object.
● Use the private index variable to control where ForecastDay is
added to the array.
void printForecastForDay(string);
● Take a date as an argument and shows the forecast for that day.
(when day == forecastDay)
void printFourDayForecast(string);
● Takes a date as an argument and shows the forecast issued on that
date and for the next three days (see expected output below). For
example, for a date of 1-26-2016, you would show the forecast for
1-26-2016 issued on 1-26-2016 as well as the forecast for 1-27,
1-28, and 1-29 issued on 1-26.
double calculateTotalPrecipitation();
● Returns the sum of the precipitation in the data set. The
accumulator is modified only when forecastDay is the current day
(day == forecastDay).
void printLastDayItRained();
● Shows the date of the last measureable precipitation.
(when day == forecastDay)
void printLastDayAboveTemperature(int);
● Takes an integer (temperature) as an argument and shows the date
for the last day above that temperature. If no days are above the
temperature, prints “No days above that temperature.”
(when day == forecastDay)
void printTemperatureForecastDifference(string);
● Takes a date as an argument and shows the temperature forecast for
that date using the three days leading up to the date and the
day-of forecast.
string getFirstDayInData();
● Returns the first date in the data with a day-of forecast, i.e. day
= forecastDay
string getLastDayInData();
● Returns the last date in the data with a day-of forecast, i.e. day
= forecastDay
Functionality in main()
CSCI 1310 – Assignment 6 Due Saturday, Mar 10, by 08:00 am
In your main() function, you will need to open the file, read in the data, and create an
instance of WeatherForecaster. Once you’ve populated a ForecastDay instance, you
add it to your WeatherForecaster instance using the addDayToData method.
Once you’re confident that the array data is correct, call the methods to analyze the
data and print the results. Your output should look like this:
Forecast statistics:
Last day it rained: