Rainfall Write a program that uses nested loops to collect data and calculate th
ID: 3542494 • Letter: R
Question
Rainfall
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 for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve 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 chould display the number of months, the total inches of rainfall, and the average rainfall per month for the entire period.
Can someone please put this into psudocode?
Explanation / Answer
number number_of_months
number total_rainfall
display Please enter the number of years
read number_of_years
for every year in number_of_years
for every month in 1 to 12
display Please enter the rainfall in inches
read number_of_inches
total_rainfall = total_rainfall + number_of_inches
end for
end for
number_of_months = number_of_years * 12
display number of months is number_of_months
display total rainfall is total_rainfall
display average rainfall is (total_rainfall / number_of_months)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.