SlideShare a Scribd company logo
1 of 7
Download to read offline
Assignment Details There is a .h 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; }; 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 printDaysInData(); • Show the dates in the data set where the day and
the forecast day are the same. void printForecastForDay(string); • Take a date as an argument
and shows the forecast for that date. CSCI 1310 - Assignment 6 Due Saturday, Oct 15, by 12:30
pm void printFourDayForecast(string); • Takes a date as an argument and shows the forecast
issued on that date and for the next three days. 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. void printLastDayItRained(); • Shows the date of the last measureable
precipitation. void printLastDayAboveTemperature(int); • Takes an integer 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.” void printTemperatureForecastDifference(string); •
Takes a date as an argument and shows the temperature forecast for that date for the three days
leading up to the date and the day-of forecast. void printPredictedVsActualRainfall(int); • Shows
the difference between the predicted and actual rainfall total in the entire data set. • The
argument to the function is the number of forecast days away. For example, the forecast for 1-27-
2016 is one day away from 1- 26-2016. 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 Challenge functions 1. There is
another header file on Moodle called WeatherForecastChallenge.h that uses a vector to store the
future forecast days. Instead of including all data in the yearData array, you can include only
days where the day = forecast day in the array. The other forecast days are stored in the vector.
For example, the forecast for 1-26 issued on 1-26 is stored in the array. That element in the array
then has a vector that stores the forecasts for 1-27, 1-28, and 1-29. Functionality in main() 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. CSCI 1310 - Assignment 6 Due
Saturday, Oct 15, by 12:30 pm 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: Total rainfall: First date in data: Last date in data: Your main
function should prompt the user for a date and pass that date as an argument to the
printForecastForDay and printFourDayForecast methods to display the information. If the date is
not found in the file, your program should print “Date not found.” WeatherForecaster wf;
cout<<”Enter a date:”; getline(cin, date); wf.printForecastForDay(date); Information displayed
in printForecastForDay: Forecast for : H: L: Humidity: Avg. wind: Avg. wind direction: Max
wind: Max wind direction: Precipitation: For printFourDayForecast, repeat information for all
four days. Information displayed for printDaysInForecast: 1-26-2016 1-27-2016 1-28-2016 . . .
9-29-2016 Information displayed for getFirstDayInData: 1-26-2016 Information displayed for
getLastDayInData: CSCI 1310 - Assignment 6 Due Saturday, Oct 15, by 12:30 pm 9-29-2016
Information displayed for printPredictedVsActualRainfall: Predicted rainfall in -day forecast
inches Actual rainfall in day-of forecast inches Information displayed for
printTemperatureForecastDifference: Forecast for issued on H: L: Forecast for issued on H: L:
Forecast for issued on H: L: Actual forecast for H: L: Information for
calculateTotalPrecipitation: Total precipitation: inches Information for printLastDayItRained: It
last rained on: Information for printLastDayAboveTemperature: It was above on
Solution
#include
#include "WEATHERFORECASTER.h"
using namespace std;
int main()
{
WeatherForecaster yD;
yD.printDaysInData();
//yD.addDayToData();
// yD.printForecastForDay("9-16-2016");
yD.getFirstDayInData();
yD.getLastDayInData();
}
Here is the header file:
#ifndef WEATHERFORECASTER_H
#define WEATHERFORECASTER_H
#include
struct ForecastDay{
std::string day;
std::string forecastDay;
int highTemp;
int lowTemp;
int humidity;
int avgWind;
std::string avgWindDir;
int maxWind;
std::string maxWindDir;
double precip;
};
class WeatherForecaster
{
public:
WeatherForecaster();
~WeatherForecaster();
void addDayToData(ForecastDay);
void printDaysInData(); //prints the unique dates in the data
void printForecastForDay(std::string);
void printFourDayForecast(std::string);
double calculateTotalPrecipitation();
void printLastDayItRained();
void printLastDayAboveTemperature(int); //argument is the temperature
void printTemperatureForecastDifference(std::string);
void printPredictedVsActualRainfall(int); //argument is days out, such as 1 = 1 day out, 2 = 2
days out, 3 = 3 days out
std::string getFirstDayInData();
std::string getLastDayInData();
protected:
private:
int arrayLength = 984;
int index;
ForecastDay yearData[984]; //data for each day
};
#endif // WEATHERFORECASTER_H
Here is the source file:
#include "WEATHERFORECASTER.h"
#include
#include
#include
#include
#include
using namespace std;
WeatherForecaster::WeatherForecaster()
{
//ctor
ifstream Fore; //Open up the file DATABOULDER.csv for weather data
Fore.open("DATABOULDER.csv");
if (Fore.fail()) //If it fails nothing will happen
{
}
else
{ //Otherwise open the file and begin sorting the data
string weather; //Create a string called weather
int lineIndex = 0; //Create a counter for the lines
while (getline(Fore, weather, ' ')) //Move through each line of the data by stopping at a
character return
{ //Set the weather variable to that whole line of data
stringstream ss; //Create a stream using the weather string
ss << weather;
int weatherIndex = 0; //Create a new Index counter for each piece of data within the line
while (getline(ss, weather, ',')) //Go through the line and every comma store that as a
weatherIndex
{
if (weatherIndex == 0) //Begin setting the pieces of the array beginning with the first index
{
string day = yearData[lineIndex].day; //If the index is 0 then set it as the .day extension
yearData[lineIndex].day = weather; //Set this equal to the weather variable in order to get the
actual piece of data
}
else if (weatherIndex == 1) //If Index is 1 then this is the forecast day so use that extension
{
string forecastDay = yearData[lineIndex].forecastDay;
yearData[lineIndex].forecastDay = weather; //Set that equal to the weather variable to get actual
data
}
else if (weatherIndex == 2) //If the Index is 2 then this is the high temp
{
istringstream convert(weather); //First convert weather so it can take ints
int highTemp = 0; //Create a highTemp int variable
string strHighTemp = ""; //Create a string to use with the string for converting the highTemp
strHighTemp = weather.substr(2, 2); //This allows for the H: to be removed and only a number
or int
if (!(istringstream(strHighTemp) >> highTemp)) highTemp = 0;//Converting string highTemp to
int highTemp and if it fails set highTemp to 0
yearData[lineIndex].highTemp = highTemp;
}
else if (weatherIndex == 3)
{
istringstream convert(weather); //Perform the exact same steps as previous for low temperatures
int lowTemp = 0;
string strLowTemp = "";
strLowTemp = weather.substr(2, 2);
if (!(istringstream(strLowTemp) >> lowTemp)) lowTemp = 0;
yearData[lineIndex].lowTemp = lowTemp;
}
else if (weatherIndex == 4) //If Index is 4 then that is humidity and we need to convert
{
istringstream convert(weather); //Convert weather to take ints
int humidity = 0; //Initialize a variable for humidity
if (!(istringstream(weather) >> humidity)) humidity = 0;//Convert string humidity to int
humidity and if it fails set humidity to 0
yearData[lineIndex].humidity = humidity; //Set this index of the array to humidity variable type
int
}
else if (weatherIndex == 5) //If Index is 5 then that is avgWind and we must convert
{
istringstream convert(weather); //Convert weather to take ints
int avgWind = 0; //Initialize variable for avgWind
if (!(istringstream(weather) >> avgWind)) avgWind = 0; //Convert string avgWind to int
avgWind and if it fails set avgWind to 0
yearData[lineIndex].avgWind = avgWind; //Set this index of the array to the avgWind variable
type int
}
else if (weatherIndex == 6) //If Index is 6 then it is the avg Wind Direction
{
yearData[lineIndex].avgWindDir = weather; //Set this index of the array to weather since it is a
string
}
else if (weatherIndex == 7) //If Index is 7 then it is max Wind
{
istringstream convert(weather); //Convert weather to take ints
int maxWind = 0; //Initialize variable for maxWind
if (!(istringstream(weather) >> maxWind)) maxWind = 0;//Convert string maxWind to int
maxWind and if it fails set maxWind to 0
yearData[lineIndex].maxWind = maxWind; //Set this index of the array to the maxWind
variable type int
}
else if (weatherIndex == 8) //If Index is 8 then it is max Wind Direction
{
yearData[lineIndex].maxWindDir = weather; //Set equal to weather since it is a string
}
else if (weatherIndex == 9) //If Index is 9 then it is precipitation
{
istringstream convert(weather); //Convert weather to take doubles
double precip = 0; //Initialize variable for precipitation type double
if (!(istringstream(weather) >> precip)) precip = 0;//Convert string precip to int precip and if it
fails set it to 0
yearData[lineIndex].precip = precip; //Set this index of the array to the precip variable of type
double
}
weatherIndex++; //Increment each weatherIndex to get all lines
}
lineIndex++; //Increment each lineIndex to get all pieces from the lines
}
}
}
WeatherForecaster::~WeatherForecaster()
{
//dtor
}
/*void WeatherForecaster::addDayToData(ForecastDay day)
{
if(index < arrayLength)
{
yearData[index].forecastDay = ForecastDay;
index++;
}
else
{
cout<<"array full"<

More Related Content

Similar to Assignment Details There is a .h file on Moodle that provides a defi.pdf

Hi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdfHi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdf
Ankitchhabra28
 
HEAT WAVES AND EFFETCS IN THE INDIAN SUB CONTINENT
HEAT WAVES AND EFFETCS  IN THE INDIAN SUB CONTINENTHEAT WAVES AND EFFETCS  IN THE INDIAN SUB CONTINENT
HEAT WAVES AND EFFETCS IN THE INDIAN SUB CONTINENT
SriSravani2
 
COMP41680 - Sample API Assignment¶In [5] .docx
COMP41680 - Sample API Assignment¶In [5] .docxCOMP41680 - Sample API Assignment¶In [5] .docx
COMP41680 - Sample API Assignment¶In [5] .docx
pickersgillkayne
 
Need to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfNeed to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdf
anjandavid
 
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Faysal Shaarani (MBA)
 

Similar to Assignment Details There is a .h file on Moodle that provides a defi.pdf (20)

Pumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency AnalysisPumps, Compressors and Turbine Fault Frequency Analysis
Pumps, Compressors and Turbine Fault Frequency Analysis
 
Hi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdfHi,I have implemented increment() method. Please find the below up.pdf
Hi,I have implemented increment() method. Please find the below up.pdf
 
unit 5_Real time Data Analysis vsp.pptx
unit 5_Real time Data Analysis  vsp.pptxunit 5_Real time Data Analysis  vsp.pptx
unit 5_Real time Data Analysis vsp.pptx
 
FINAL [Autosaved]
FINAL [Autosaved]FINAL [Autosaved]
FINAL [Autosaved]
 
Unit 5 Time series Data Analysis.pdf
Unit 5 Time series Data Analysis.pdfUnit 5 Time series Data Analysis.pdf
Unit 5 Time series Data Analysis.pdf
 
R time series analysis
R   time series analysisR   time series analysis
R time series analysis
 
Script Files
Script FilesScript Files
Script Files
 
weatherr.pptx
weatherr.pptxweatherr.pptx
weatherr.pptx
 
Observer and Decorator Pattern
Observer and Decorator PatternObserver and Decorator Pattern
Observer and Decorator Pattern
 
HEAT WAVES AND EFFETCS IN THE INDIAN SUB CONTINENT
HEAT WAVES AND EFFETCS  IN THE INDIAN SUB CONTINENTHEAT WAVES AND EFFETCS  IN THE INDIAN SUB CONTINENT
HEAT WAVES AND EFFETCS IN THE INDIAN SUB CONTINENT
 
Chapter 16-spreadsheet1 questions and answer
Chapter 16-spreadsheet1  questions and answerChapter 16-spreadsheet1  questions and answer
Chapter 16-spreadsheet1 questions and answer
 
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
Samantha Wang [InfluxData] | Best Practices on How to Transform Your Data Usi...
 
Unit 2 part-2
Unit 2 part-2Unit 2 part-2
Unit 2 part-2
 
PART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORTPART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORT
 
Observer Pattern
Observer PatternObserver Pattern
Observer Pattern
 
Matlab data import
Matlab data importMatlab data import
Matlab data import
 
Weather scraper for your data warehouse
Weather scraper for your data warehouseWeather scraper for your data warehouse
Weather scraper for your data warehouse
 
COMP41680 - Sample API Assignment¶In [5] .docx
COMP41680 - Sample API Assignment¶In [5] .docxCOMP41680 - Sample API Assignment¶In [5] .docx
COMP41680 - Sample API Assignment¶In [5] .docx
 
Need to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfNeed to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdf
 
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)Date and Timestamp Types In Snowflake (By Faysal Shaarani)
Date and Timestamp Types In Snowflake (By Faysal Shaarani)
 

More from jyothimuppasani1

Help please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdfHelp please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdf
jyothimuppasani1
 
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdfhow can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
jyothimuppasani1
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdf
jyothimuppasani1
 
File encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdfFile encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdf
jyothimuppasani1
 
Explain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdfExplain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdf
jyothimuppasani1
 
Find the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdfFind the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdf
jyothimuppasani1
 
Do you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdfDo you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdf
jyothimuppasani1
 
Discuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdfDiscuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdf
jyothimuppasani1
 
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdfData Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
jyothimuppasani1
 
•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf
jyothimuppasani1
 
You are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdfYou are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdf
jyothimuppasani1
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdf
jyothimuppasani1
 
What are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdfWhat are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdf
jyothimuppasani1
 

More from jyothimuppasani1 (20)

How does an open source operating system like Linux® affect Internet.pdf
How does an open source operating system like Linux® affect Internet.pdfHow does an open source operating system like Linux® affect Internet.pdf
How does an open source operating system like Linux® affect Internet.pdf
 
Help please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdfHelp please!!(Include your modified DList.java source code file in.pdf
Help please!!(Include your modified DList.java source code file in.pdf
 
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdfhow can I replace the Newsfeed text with a custom on in SharePoi.pdf
how can I replace the Newsfeed text with a custom on in SharePoi.pdf
 
Hello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdfHello!This is Java assignment applet.Can someone help me writing.pdf
Hello!This is Java assignment applet.Can someone help me writing.pdf
 
For each of the following reseach questions identify the observation.pdf
For each of the following reseach questions identify the observation.pdfFor each of the following reseach questions identify the observation.pdf
For each of the following reseach questions identify the observation.pdf
 
Find an Eulerian trail in the following graph. Be sure to indicate th.pdf
Find an Eulerian trail in the following graph. Be sure to indicate th.pdfFind an Eulerian trail in the following graph. Be sure to indicate th.pdf
Find an Eulerian trail in the following graph. Be sure to indicate th.pdf
 
File encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdfFile encryption. [32] Write a program which accepts a filename as a .pdf
File encryption. [32] Write a program which accepts a filename as a .pdf
 
Explain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdfExplain the relevance that medical standards of practice have to one.pdf
Explain the relevance that medical standards of practice have to one.pdf
 
Find the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdfFind the mission and values statements for four different hospita.pdf
Find the mission and values statements for four different hospita.pdf
 
Did colonial rule freeze colonized societies by preserving old s.pdf
Did colonial rule freeze colonized societies by preserving old s.pdfDid colonial rule freeze colonized societies by preserving old s.pdf
Did colonial rule freeze colonized societies by preserving old s.pdf
 
Do you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdfDo you think that nonhuman animals have interests Does this mean th.pdf
Do you think that nonhuman animals have interests Does this mean th.pdf
 
Discuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdfDiscuss the importance of recognizing and implementing different ent.pdf
Discuss the importance of recognizing and implementing different ent.pdf
 
Considering the challenges she is facing, what Anitas plan before .pdf
Considering the challenges she is facing, what Anitas plan before .pdfConsidering the challenges she is facing, what Anitas plan before .pdf
Considering the challenges she is facing, what Anitas plan before .pdf
 
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdfData Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
Data Structure in C++Doubly Linked Lists of ints httpstaffwww.pdf
 
Conceptual skills are most important at theSolutionConceptual .pdf
Conceptual skills are most important at theSolutionConceptual .pdfConceptual skills are most important at theSolutionConceptual .pdf
Conceptual skills are most important at theSolutionConceptual .pdf
 
A variable whose scope is restricted to the method where it was decl.pdf
A variable whose scope is restricted to the method where it was decl.pdfA variable whose scope is restricted to the method where it was decl.pdf
A variable whose scope is restricted to the method where it was decl.pdf
 
•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf•Design (create) 3 questions for a quiz show game and design regular.pdf
•Design (create) 3 questions for a quiz show game and design regular.pdf
 
You are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdfYou are to write a GUI program that will allow a user to buy, sell a.pdf
You are to write a GUI program that will allow a user to buy, sell a.pdf
 
write the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdfwrite the To Dos to get the exact outputNOte A valid Fraction .pdf
write the To Dos to get the exact outputNOte A valid Fraction .pdf
 
What are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdfWhat are the factors that contribute to H+ gain or loss How do lung.pdf
What are the factors that contribute to H+ gain or loss How do lung.pdf
 

Recently uploaded

QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
httgc7rh9c
 

Recently uploaded (20)

Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17Model Attribute _rec_name in the Odoo 17
Model Attribute _rec_name in the Odoo 17
 
VAMOS CUIDAR DO NOSSO PLANETA! .
VAMOS CUIDAR DO NOSSO PLANETA!                    .VAMOS CUIDAR DO NOSSO PLANETA!                    .
VAMOS CUIDAR DO NOSSO PLANETA! .
 
How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17How to Add a Tool Tip to a Field in Odoo 17
How to Add a Tool Tip to a Field in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Economic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food AdditivesEconomic Importance Of Fungi In Food Additives
Economic Importance Of Fungi In Food Additives
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
PANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptxPANDITA RAMABAI- Indian political thought GENDER.pptx
PANDITA RAMABAI- Indian political thought GENDER.pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 

Assignment Details There is a .h file on Moodle that provides a defi.pdf

  • 1. Assignment Details There is a .h 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; }; 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 printDaysInData(); • Show the dates in the data set where the day and the forecast day are the same. void printForecastForDay(string); • Take a date as an argument and shows the forecast for that date. CSCI 1310 - Assignment 6 Due Saturday, Oct 15, by 12:30 pm void printFourDayForecast(string); • Takes a date as an argument and shows the forecast issued on that date and for the next three days. 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. void printLastDayItRained(); • Shows the date of the last measureable precipitation. void printLastDayAboveTemperature(int); • Takes an integer 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.” void printTemperatureForecastDifference(string); • Takes a date as an argument and shows the temperature forecast for that date for the three days leading up to the date and the day-of forecast. void printPredictedVsActualRainfall(int); • Shows the difference between the predicted and actual rainfall total in the entire data set. • The argument to the function is the number of forecast days away. For example, the forecast for 1-27- 2016 is one day away from 1- 26-2016. 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 Challenge functions 1. There is another header file on Moodle called WeatherForecastChallenge.h that uses a vector to store the future forecast days. Instead of including all data in the yearData array, you can include only days where the day = forecast day in the array. The other forecast days are stored in the vector. For example, the forecast for 1-26 issued on 1-26 is stored in the array. That element in the array then has a vector that stores the forecasts for 1-27, 1-28, and 1-29. Functionality in main() In your main() function, you will need to open the file, read in the data, and create an instance of
  • 2. WeatherForecaster. Once you’ve populated a ForecastDay instance, you add it to your WeatherForecaster instance using the addDayToData method. CSCI 1310 - Assignment 6 Due Saturday, Oct 15, by 12:30 pm 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: Total rainfall: First date in data: Last date in data: Your main function should prompt the user for a date and pass that date as an argument to the printForecastForDay and printFourDayForecast methods to display the information. If the date is not found in the file, your program should print “Date not found.” WeatherForecaster wf; cout<<”Enter a date:”; getline(cin, date); wf.printForecastForDay(date); Information displayed in printForecastForDay: Forecast for : H: L: Humidity: Avg. wind: Avg. wind direction: Max wind: Max wind direction: Precipitation: For printFourDayForecast, repeat information for all four days. Information displayed for printDaysInForecast: 1-26-2016 1-27-2016 1-28-2016 . . . 9-29-2016 Information displayed for getFirstDayInData: 1-26-2016 Information displayed for getLastDayInData: CSCI 1310 - Assignment 6 Due Saturday, Oct 15, by 12:30 pm 9-29-2016 Information displayed for printPredictedVsActualRainfall: Predicted rainfall in -day forecast inches Actual rainfall in day-of forecast inches Information displayed for printTemperatureForecastDifference: Forecast for issued on H: L: Forecast for issued on H: L: Forecast for issued on H: L: Actual forecast for H: L: Information for calculateTotalPrecipitation: Total precipitation: inches Information for printLastDayItRained: It last rained on: Information for printLastDayAboveTemperature: It was above on Solution #include #include "WEATHERFORECASTER.h" using namespace std; int main() { WeatherForecaster yD; yD.printDaysInData(); //yD.addDayToData(); // yD.printForecastForDay("9-16-2016"); yD.getFirstDayInData(); yD.getLastDayInData(); } Here is the header file:
  • 3. #ifndef WEATHERFORECASTER_H #define WEATHERFORECASTER_H #include struct ForecastDay{ std::string day; std::string forecastDay; int highTemp; int lowTemp; int humidity; int avgWind; std::string avgWindDir; int maxWind; std::string maxWindDir; double precip; }; class WeatherForecaster { public: WeatherForecaster(); ~WeatherForecaster(); void addDayToData(ForecastDay); void printDaysInData(); //prints the unique dates in the data void printForecastForDay(std::string); void printFourDayForecast(std::string); double calculateTotalPrecipitation(); void printLastDayItRained(); void printLastDayAboveTemperature(int); //argument is the temperature void printTemperatureForecastDifference(std::string); void printPredictedVsActualRainfall(int); //argument is days out, such as 1 = 1 day out, 2 = 2 days out, 3 = 3 days out std::string getFirstDayInData(); std::string getLastDayInData(); protected: private: int arrayLength = 984;
  • 4. int index; ForecastDay yearData[984]; //data for each day }; #endif // WEATHERFORECASTER_H Here is the source file: #include "WEATHERFORECASTER.h" #include #include #include #include #include using namespace std; WeatherForecaster::WeatherForecaster() { //ctor ifstream Fore; //Open up the file DATABOULDER.csv for weather data Fore.open("DATABOULDER.csv"); if (Fore.fail()) //If it fails nothing will happen { } else { //Otherwise open the file and begin sorting the data string weather; //Create a string called weather int lineIndex = 0; //Create a counter for the lines while (getline(Fore, weather, ' ')) //Move through each line of the data by stopping at a character return { //Set the weather variable to that whole line of data stringstream ss; //Create a stream using the weather string ss << weather; int weatherIndex = 0; //Create a new Index counter for each piece of data within the line while (getline(ss, weather, ',')) //Go through the line and every comma store that as a weatherIndex { if (weatherIndex == 0) //Begin setting the pieces of the array beginning with the first index { string day = yearData[lineIndex].day; //If the index is 0 then set it as the .day extension
  • 5. yearData[lineIndex].day = weather; //Set this equal to the weather variable in order to get the actual piece of data } else if (weatherIndex == 1) //If Index is 1 then this is the forecast day so use that extension { string forecastDay = yearData[lineIndex].forecastDay; yearData[lineIndex].forecastDay = weather; //Set that equal to the weather variable to get actual data } else if (weatherIndex == 2) //If the Index is 2 then this is the high temp { istringstream convert(weather); //First convert weather so it can take ints int highTemp = 0; //Create a highTemp int variable string strHighTemp = ""; //Create a string to use with the string for converting the highTemp strHighTemp = weather.substr(2, 2); //This allows for the H: to be removed and only a number or int if (!(istringstream(strHighTemp) >> highTemp)) highTemp = 0;//Converting string highTemp to int highTemp and if it fails set highTemp to 0 yearData[lineIndex].highTemp = highTemp; } else if (weatherIndex == 3) { istringstream convert(weather); //Perform the exact same steps as previous for low temperatures int lowTemp = 0; string strLowTemp = ""; strLowTemp = weather.substr(2, 2); if (!(istringstream(strLowTemp) >> lowTemp)) lowTemp = 0; yearData[lineIndex].lowTemp = lowTemp; } else if (weatherIndex == 4) //If Index is 4 then that is humidity and we need to convert { istringstream convert(weather); //Convert weather to take ints int humidity = 0; //Initialize a variable for humidity if (!(istringstream(weather) >> humidity)) humidity = 0;//Convert string humidity to int humidity and if it fails set humidity to 0 yearData[lineIndex].humidity = humidity; //Set this index of the array to humidity variable type
  • 6. int } else if (weatherIndex == 5) //If Index is 5 then that is avgWind and we must convert { istringstream convert(weather); //Convert weather to take ints int avgWind = 0; //Initialize variable for avgWind if (!(istringstream(weather) >> avgWind)) avgWind = 0; //Convert string avgWind to int avgWind and if it fails set avgWind to 0 yearData[lineIndex].avgWind = avgWind; //Set this index of the array to the avgWind variable type int } else if (weatherIndex == 6) //If Index is 6 then it is the avg Wind Direction { yearData[lineIndex].avgWindDir = weather; //Set this index of the array to weather since it is a string } else if (weatherIndex == 7) //If Index is 7 then it is max Wind { istringstream convert(weather); //Convert weather to take ints int maxWind = 0; //Initialize variable for maxWind if (!(istringstream(weather) >> maxWind)) maxWind = 0;//Convert string maxWind to int maxWind and if it fails set maxWind to 0 yearData[lineIndex].maxWind = maxWind; //Set this index of the array to the maxWind variable type int } else if (weatherIndex == 8) //If Index is 8 then it is max Wind Direction { yearData[lineIndex].maxWindDir = weather; //Set equal to weather since it is a string } else if (weatherIndex == 9) //If Index is 9 then it is precipitation { istringstream convert(weather); //Convert weather to take doubles double precip = 0; //Initialize variable for precipitation type double if (!(istringstream(weather) >> precip)) precip = 0;//Convert string precip to int precip and if it fails set it to 0 yearData[lineIndex].precip = precip; //Set this index of the array to the precip variable of type
  • 7. double } weatherIndex++; //Increment each weatherIndex to get all lines } lineIndex++; //Increment each lineIndex to get all pieces from the lines } } } WeatherForecaster::~WeatherForecaster() { //dtor } /*void WeatherForecaster::addDayToData(ForecastDay day) { if(index < arrayLength) { yearData[index].forecastDay = ForecastDay; index++; } else { cout<<"array full"<