Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask the user for the number of 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 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.
Write a
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.
Add additional loops to validate the input:
Do not accept a number less than 1 for the number of years. Continue to prompt the user for a number until a valid number is entered.
Do not accept negative numbers for the monthly rainfall. Continue to prompt the user for a number until a valid number is entered
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images