Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The goal is to write a complete C++ program to analyze monthly rainfall data. The data well use is from Chicagos Midway airport, but the

The goal is to write a complete C++ program to analyze monthly rainfall data. The data well use is from Chicagos Midway airport, but the data could be from any location. The file format consists of an information row, followed by N > 0 rows of data. For example, heres the contents of the input file midway-1.txt:

Chicago_Midway_Airport_2015_2017

2015 1.23 0.24 0.48 2.94 4.13 4.37 2.25 3.46 4.97 1.59 4.14 5.40

2016 0.65 0.21 3.05 2.50 5.56 1.56 4.95 6.42 1.19 4.22 1.66 1.25

2017 2.65 2.40 4.18 6.27 3.77 2.60 4.23 1.90 0.56 5.98 2.33 0.17

Each data row starts with an integer year, followed by 12 real numbers denoting the inches of rainfall for each month (Jan, Feb, ..., Dec). The program analyzes this data and outputs the following:

1. The average rainfall for each year

2. The trend (=, -, --, +, ++) as compared to the previous year

3. The average rainfall for each month (across all years)

4. The maximum rainfall amount and date

5. The minimum rainfall amount and date

This trend is determined by comparing the years average to the previous year:

if -0.1 < difference < 0.1, the trend is =

if -1.0 < difference <= -0.1, the trend is -

if the diff is -1.0 or smaller, the trend is - -

if 0.1 <= difference < 1.0, the trend is +

if the diff is 1.0 or larger, the trend is ++

Taking "midway-1.txt", the output should read:

Average by year (inches):

2015: 2.93333

2016: 2.76833 (-)

2017: 3.08667 (+)

Trends: = 0, + 1, - 1

Average by month (inches):

Jan: 1.51

Feb: 0.95

Mar: 2.57

Apr: 3.90333

May: 4.48667

Jun: 2.84333

Jul: 3.81

Aug: 3.92667

Sep: 2.24

Oct: 3.93

Nov: 2.71

Dec: 2.27333

Maximum rainfall: 6.42 inches on Aug 2016

Minimum rainfall: 0.17 inches on Dec 2017

** Done **

Your program must meet the following requirements:

1. Your program must have at least 3 non-trivial functions. A non-trivial function has at least one parameter, and either contains a loop or performs some sort of computation requiring 5 or more lines of code. For example, a useful function in this program will be one that is given the month #(say 1..12 or 0..11) and returns the name of that month:

string Month2String(int month)

{

if (month == 1)

return "Jan";

else if...

}

This function will be useful when you need to output the month. An input function is also a common (and good) idea.

2. Your program must contain at least one array, either 1D or 2D, for storing / analyzing the data. For example, you could input and store all the data in a 2D array of size 200x13. Alternatively, notice the yearly averages could be computed as you input the data, so perhaps you store only the monthly sums in a 1D array, and then compute the averages after all the data has been input.

3. You may open the input file only once. You cannot repeatedly open and close the input file.

Please include all the following above and do not forget the trends.

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

Expert Oracle9i Database Administration

Authors: Sam R. Alapati

1st Edition

1590590228, 978-1590590225

More Books

Students also viewed these Databases questions