Question
Write a complete C++ program that inputs rainfall data collected at Chicago Midway airport, and outputs the average rainfall for each year. The format of the input data is as follows. There are N>0 lines, each containing 13 values: a year followed by 12 real numbers denoting the amount of rainfall for the 12 months of January, February, March, …, December. The last line of the input consists of a single value -1. Here’s one possible input sequence:
For this input, your program should produce the following output, which is the average rainfall for each year:
Like the previous exercise, the provided code is actually spread across 2 C++ source files: “main.cpp” and “analysis.cpp”. Start by reviewing the code for “main.cpp” which is visible in the editor pane — note that this code is read-only (you cannot modify it). In particular, focus on the code within the while loop. Once the year is input, you’ll see that the InputYearOfDataAndReturnAverage() function is called to input the remaining 12 values on that line, then compute and return the average. The average is stored, output, and then the next year is input and the process repeated — until -1 is input.
Now let’s review the code for the user-defined function. Above the editor pane you’ll see the text “Current file: main.cpp”, with a little drop-down arrow to the right. Click the drop-down and select “analysis.cpp”. Then, immediately click the link “Load default template…” — this avoids a bug that appears in some web browsers (which fail to properly load the file). You only need to do this once, the first time you view the file.
The editor pane should now be displaying the code for the user-defined function InputYearOfDataAndReturnAverage. Your job is to modify the body of this function so that it inputs exactly 12 real numbers and returns the average as a real number. Note that we are breaking the rule of “functions do not input nor output” — in this case your function should use cin to input the necessary rainfall values for the current year. However, your function should not use cout, but must instead return the average. When the function is correctly implemented, you will pass all 3 test cases.
Current file.main.cpp File is marked as read only 1 /*main.cpp*/ 3 #include¢ostream» 4 #include 6 using namespace std; 9 // declarations of user-defined functions: 11 double InputYearOfDataAndReturnAverage(); 12 13 14 int main() 15 16 int 17 18 19 cin year; 28 year; double avg; 21 I 22 1 process each year of data and output the average: 23 / 24 while (year- -1) 25 26 27 28 29 30 31 32 avg = InputYearOfDataAndReturnAverage(); cin >> year; return e; 34 35
GraduateWriterHelp.com is an online academic writing platform that provides extensive assistance to graduate school students as they work through their research projects, papers and dissertations. GraduateWriterHelp.com gives students access to experienced professionals who can provide the help they need in a timely and efficient manner. The service offers a wide range of services, including editing, proofreading, formatting, researching and more that can give students the confidence they need to write the perfect paper or dissertation for their chosen subject matter.
Services Offered by GraduateWriterHelp.com
GraduateWriterHelp.com offers a wealth of different services designed to make research projects easier for graduate school students. These include editing, proofreading, formatting and researching services, all tailored specifically for graduate-level studies such as PhDs or Master’s degrees in any field from business administration to engineering or even psychology – all with the aim of helping busy students find success in their academics without having to sacrifice other important commitments like family time or work hours towards earning a living wage outside of college hours.
The Benefits of Using GraduateWriterHelp.com
Using GraduateWriterHelp.com gives you access to experts from all over the world who are highly qualified and experienced in helping graduate-level students to complete successful projects in various fields quickly and efficiently – something that would otherwise be difficult, if not impossible, given tight deadlines associated with most Ph.D./Master’s degree programs today. Moreover, using this platform makes it easier for students to keep up with multiple research tasks simultaneously since there are so many different experts available on tap at any one time – no longer will you have to put off studying one topic while focusing on another because of lack of resources! Additionally, having access to professional editors, proofreaders, but also formatters means that quality control standards aren’t sacrificed when finishing major pieces – since these individuals understand what makes up good academic writing better than anyone else and can offer guidance on how best one should go about making improvements along those lines. Finally, there is also an added cost-saving benefit associated with utilizing Graduate Writer Help compared to hiring an independent contractor (which could potentially run into thousands depending on length/complexity).
This service allows users only pay for what students need, which tends to be much lower overall because customers pay per hour rather than project basis, thus resulting to greater financial flexibility, especially for those just starting out postgraduate studies looking to conserve some pennies here there whenever possible!
Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.
You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.
Read moreEach paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.
Read moreThanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.
Read moreYour email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.
Read moreBy sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.
Read more