Question: Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program asks the user

Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program asks the user for the number of years. The outer loop will iterate once for each year. The inner loop will iterate 3 times. Each iteration on the inner loop will ask the user for the inches of rainfall for that month. After all iterations, the program should display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period.

I need the program to display the number of months, the total inches of rainfall, and the average rainfall per month for the each year separately. Here is an example of the program:

Enter number of years: 2 Rainfall in year 1 : Enter Rainfall in month 1 : 1 Enter Rainfall in month 2 : 2 Enter Rainfall in month 3 : 3 Total rainfall this year= 6.0 Average rainfall this year = 2.0 Rainfall in year 2 : Enter Rainfall in month 1 : 3 Enter Rainfall in month 2 : 4 Enter Rainfall in month 3 : 5 Total rainfall this year= 12.0 Average rainfall this year = 4.0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!