Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that uses nested loops to collect data and calculate the average rainfall over period of years. 1. The program has a method

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

1. The program has a method named getYear to ask the user to enter the number of years and return the number. (Input validation: Do not accept numbers less than 1 for the number of years)

2.The program has a method named getRainfall to ask the user to enter the number of inches of rainfall for a month and return that number. (Input validation: Do not accept negative numbers for the rainfall)

3. The program has a method named calcAvgRain to calculate and return the average monthly rainfall over a period of years. It accepts the number of years as argument. The method uses a nested loop to collect the rainfall for those many 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 call the getRainfall method to get the 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.

in java program

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_2

Step: 3

blur-text-image_3

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

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions

Question

What basic questions can HR analytics answer?

Answered: 1 week ago