Answered step by step
Verified Expert Solution
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!
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 monthStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started