Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need some assistance with this lab! I'm not sure what I'm doing wrong. Thank you! Please write in Java! 1. To practice nested loops

I need some assistance with this lab! I'm not sure what I'm doing wrong. Thank you! Please write in Java!

image text in transcribed

1. To practice nested loops 2 To earn extra credit Assignment Extra Credit B Write a Java program that uses nested loops to collect data and calculate the average rainfall over a period 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. Requirements Do not accept a number less than 1 for the number of years. Print Must enter a number 1 or greater and stop the program. Do not accept negative numbers for the monthly rainfall. Print Rainfall must be 0 or greater and stop program The prompt for years should read: "Enter the number of years The prompt for months should read: "Enter the inches of rainfall for month n: Samples of program execution (as if run on UNIX) > java ExtracreditiB Enter the number of years: 2 Enter the inches of rainfall for month 1: 2.4 Enter the inches of rainfal1 for month 2: 3.1 Enter the inches of rainfall for month 3:4.7 Enter the inches of rainfall for month 4: 1.3 Total number of months: 24 Total inches of rainfall: Average rainfall per month

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

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions