Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I have tried to solve this problem but couldn't, please help me solve this and to understand what I'm doing wrong. C++ please Learning Objectives

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

I have tried to solve this problem but couldn't, please help me solve this and to understand what I'm doing wrong. C++ please

Learning Objectives - Design a function to implement an algorithm - Make an overloaded function NOTE: There are 2 zyLab assignments this week. There is also one at the end of Chapter 7 . Instructions In this assignment, you will 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 is supplied to you in the template below with the function calls. Your assignment is the write the two versions of the function. The empty function prototypes are in the template. This 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; the code is already in the template, and the data file is uploaded to your zyBook. You can download the data file and look at it if you want to. The functions you will write determine the average difference between the daily high and low temperature. There are two possible ways to call these functions: (1) a pair of Julian days as data type unsigned int, or (2) the month as a enumerated variable (enum). Both functions also take a reference to a vector that points to the data. The data are already read into that vector in the template. This program will have the following features when you are cone: - Two versions 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 [There is no input] Feb 1, and Julian day 365 is Dec 31. The year 2014 was not a leap year, so you do not need to account for that. Mean Daily Temperature Change 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 here, the highest value is. 73 and the lowest is 52 , so the difference is 7352=21 for that day. Therefore, your program Will look at the data in chunks of 24 values ( 1 day each); find the minimum and maximum in each chunk, calculate the difference between these values, and then take the average of all these changes for the specified range of days. Part A This program with use an enum variable to for the month since there are only 12 different months (i.e. discrete data) and it is more clear to refer to months by name rather than a number. Define an enum datatype called Month that will have 12 values, and name these values to be 3 letter abbreviations (use first 3 letters of each month) such as JAN and FEB. You can test this part by making sure it compiles and runs without an error. This program takes no input, and the output at this point should be Part B Now write the first of the two functions. The function header (1st line) is already in the template, along with one local variable declaration. This function takes a 3 parameter list, the last two parameters are the beginning and end Julian days at data type uns igned int. The vector reference (note the \& designator) points to the hourly temperature data is in the variable named data. Complete the rest of this function by adding code to: - determine the maximum temperature change in every day between the two days (inclusive) day 1 and day 2 . Remember that the data is hourly, so there will be 24 data points for every complete day. For example if day 1=1 and day 2=2, there will be 48 data values. - Calculate the mean (average) of this temperature changes, and assign it to the local variable mean You will likely need to declare some additional local variables within the function in addition to mean. The precision of the temperature data in the file is one tenth (0.1) degrees (e.g. 23.4) You can test it at this point. The program takes no input, and the output should now be Part CNow complete the second function; the header is already in the template. This function takes 2 parameters; the second one is an enum constant of data type Month you defined in part A. An example function call using FEB is shown in the template main program. This function will determine the two end Julian days corresponding to this month and assign to variables day 1 and day 2 . The function then calls the function you already wrote (see the return statement from the template). Use a switch statement operating with the enum variable named mon. In each of the switch cases, assign the correct values to day 1 and day 2. At this point, if everything is correct, the output should be 19.333318.222422.9786 1 \#include 2 \#include 3 \#include 4 5 using namespace std; 6 P Part A 7 A add your enum declaration here 8 enum Month \{JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC\}; 9 10 /Ifunction prototypes 11 float meanDailyTempChange(vector

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probabilistic Databases

Authors: Dan Suciu, Dan Olteanu, Christopher Re, Christoph Koch

1st Edition

3031007514, 978-3031007514

More Books

Students also viewed these Databases questions