Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Usng Java.

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 to ask the user to enter the number of years and return the number. (Do not accept negative numbers for the number of years)

2. 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 methoduses 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 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.

3. The main method calls the two above methods properly.

Requirements:

1. Input validation: Do not accept negative numbers for the monthly rainfall.

2. No credit if there is only a main method in your 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

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

Database Processing Fundamentals, Design, and Implementation

Authors: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

=+Trainers from headquarters? Local trainers? Independent trainers?

Answered: 1 week ago