Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me write this code with this expected output.please add comment Thanks Problem: Average Rainfall Write a program that uses nested loops to collect

image text in transcribed

image text in transcribed

please help me write this code with this expected output.please add comment Thanks

Problem: Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. First the program should ask 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. Input Validation: Do not accept a number less than 1 for the number of years. Do not accept negative numbers for the monthly rainfall. Expected Output: For how many years, would you want to input rainfall data: @ Enter the number of years greater than 1:1 Enter the inches of rainfall for Year1 Month1 :-12 Enter a positive value for rainfall in Year1 Month1 :12 Enter the inches of rainfall for Year1 Month2:13 Enter the inches of rainfall for Year1 Month3 :14 Enter the inches of rainfall for Year1 Month4 :15 Enter the inches of rainfall for Year1 Months 16 Enter the inches of rainfall for Year1 Month6:17 Enter the inches of rainfall for Year1 Month :18 Enter the inches of rainfall for Year1 Month8 :19 Enter the inches of rainfall for Year1 Month :20 Page 2 of 2 Enter the inches of rainfall for Year1 Month10 :21 Enter the inches of rainfall for Year1 Month11 :22 Enter the inches of rainfall for Year1 Month12 : 23 Total months =12 Total rainfall in inches = 210.0 Average Rainfall each month: 17.50 inches

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

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions