Question
In C++ Format Create two versions of an overloaded function with the name meanDailyTempChange. This function will be overloaded, meaning it can be called with
In C++ Format Create two versions of an overloaded function with the name meanDailyTempChange. This function will be overloaded, meaning it can be called with different parameter lists. The main program called hw06.cpp is supplied to you with the function calls. Your assignment is the write the two version of the function and add it to the program. The program reads in the hourly average temperature in Fairbanks for the calendar year 2014. This is done using a filestream, which is similar to the the cin stream function you have already seen. Make sure the data file is in the same folder as your program. The function you will write determines the average difference between the daily high and low temperature. There are two possible inputs: (1) a pair of Julian 1 days as unsigned int, or (2) the month as a enumerated variable (enum). Both functions also take a reference to a vector that holds the data. This data are already loaded into a vector in the main program. Your program must have or do the following: Two version of the function meanDailyTempChange (i.e. overloaded). Have the enum version call the unsigned int version (nested functions). Use pass-by-reference functions. sample output 19.3333 18.2224 22.9786 *I have the data under the file type in the program.* The mean daily temperature change is the difference between the maximum and minimum that occur in a given 24 hour period. For the example day shown below, the highest value is 73 and the lowest is 52,so the difference is 73-52 = 21. Therefore, your program will look at the data in chunks of 24 values; finding the minimum and maximum in each chunk, and then taking the average of all the values in the specified range. What I have is below.
#include
using namespace std; enum Month {JAN=0, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC};
float meanDailyTempChange(vector
int main() { ifstream inFile; vector
Month thisMonth;
inFile.open("temperature2014.dat",ios::in); if (!inFile) cout << "Failed to open file "; while(inFile>>value){data.push_back(value);} inFile.close();
cout << meanDailyTempChange(data,1,3) << endl; cout << meanDailyTempChange(data,100,300) << endl; cout << meanDailyTempChange(data,FEB) << endl; return 0; }
//User input two functions here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started