High School

We appreciate your visit to Problem Statement Average Rainfall In the data files attached below monthly rainfall data for Vancouver is given in mm from the year 2017 to 2021. This page offers clear insights and highlights the essential aspects of the topic. Our goal is to provide a helpful and engaging learning experience. Explore the content and find the answers you need!

Problem Statement: Average Rainfall

In the data files attached below, monthly rainfall data for Vancouver is given in mm from the year 2017 to 2021. Each file contains 12 lines. On each line, there is a floating-point value. The first line represents rainfall measured in Vancouver during January, the second line for February, and so on.

**Task:**

Write a program that uses nested loops to read data from files and calculate some summarized values over a period of five years.

- The outer loop will iterate once for each year.
- The inner loop will iterate 12 times, once for each month. Each iteration of the inner loop will perform necessary calculations.
- The outer loop should show the yearly average rainfall and maximum monthly rainfall value for each year.

**Output Format:**

The program should display summarized data for five years as follows:

```
Year Monthly Average Rainfall Maximum Monthly Rainfall
2017 97.7 199.4
2018 110.5 254.8
2019 77.8 164.2
2020 89.3 226.0
2021 94.7 312.4
```

**Bonus Question (worth 20 points):**

Show in the output the month in which maximum rainfall occurred.

**Output with Bonus Solution:**

```
Year Monthly Average Rainfall Maximum Monthly Rainfall Month
2017 97.7 199.4 March
2018 110.5 254.8 December
2019 77.8 164.2 December
2020 89.3 226.0 January
2021 94.7 312.4 November
```

This second output, including month names, is for the bonus question. The first output without month names is the desired output for the assignment. The yellow background color mentioned is not necessary in your output; it was used to emphasize the required change.

Answer :

By following these steps, you can calculate the summarized values of average and maximum monthly rainfall for each year from 2017 to 2021, and optionally include the month with the maximum rainfall.

To solve the problem of calculating the summarized values of average and maximum monthly rainfall over a period of five years for Vancouver, we can use nested loops to read the data from the provided files.

Here is a step-by-step explanation of how we can achieve this:

1. Start by creating two variables to store the total rainfall and maximum rainfall for each year. Set both variables to 0.
2. Use an outer loop to iterate through each year from 2017 to 2021.
3. Within the outer loop, use an inner loop to iterate 12 times, representing the 12 months of the year.
4. Inside the inner loop, read the monthly rainfall data from the file and add it to the total rainfall variable for the current year.
5. Update the maximum rainfall variable for the current year if the current month's rainfall is higher than the previous maximum.
6. After the inner loop completes, calculate the average rainfall for the current year by dividing the total rainfall by 12.
7. Print the yearly average rainfall and maximum monthly rainfall for each year, without including the month names.

To solve the bonus question of showing the month with the maximum rainfall, we can add an additional variable to store the month name. Here's how we can modify the above steps to achieve this:

1. Add a new variable called "max_month" to store the month name with the maximum rainfall.
2. Inside the inner loop, check if the current month's rainfall is higher than the previous maximum. If it is, update the maximum rainfall variable and set the "max_month" variable to the current month.
3. After the inner loop completes, print the yearly average rainfall, maximum monthly rainfall, and the value of the "max_month" variable for each year.

Learn more about average in the link:

https://brainly.com/question/130657

#SPJ11

Thanks for taking the time to read Problem Statement Average Rainfall In the data files attached below monthly rainfall data for Vancouver is given in mm from the year 2017 to 2021. We hope the insights shared have been valuable and enhanced your understanding of the topic. Don�t hesitate to browse our website for more informative and engaging content!

Rewritten by : Barada