I deleted the generated code from the pasted code above because I didn't think it was necessary.import java.text.*; public class Rainfall extends javax.swing.JFrame { DecimalFormat df = new DecimalFormat("#.##"); double monthrain = 0, sum = 0, average; int years, counter = 0, counter2 = 0, monthcount = 1, i = 0; public Rainfall() { initComponents(); } private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { years = Integer.parseInt(jTextField1.getText()); jTextArea1.setText(""); while(years > 0){ jTextField1.setEditable(false); jTextField2.setEditable(true); jLabel2.setText("Enter inches of rainfall for month " + monthcount + " of year " + (counter + 1) + ":"); monthcount++; i++; monthrain = Double.parseDouble(jTextField2.getText()); while(monthrain >= 0){ while(monthcount < 14){ monthrain = Double.parseDouble(jTextField2.getText()); sum += monthrain; jTextField2.setText(""); while(monthcount == 13 || i == 12){ counter++; monthcount = 1; i = 0; if(counter == years){ average = sum / (years * 12); jTextArea1.setText("There is a total of " + (years * 12) + " months" + "\nTotal inches of rainfall is " + sum + " and" + "\nAverage inches of rainfall per month is " + df.format(average)); jTextField1.setEditable(true); jTextField2.setEditable(false); jTextField1.setText(""); jLabel2.setText(""); counter = 0; } } } } if(monthrain < 0){ years = 0; counter2++; } } if(counter2 == 1){ jTextArea1.setText("Invalid inches of rainfall for the month" + "\nPlease start over"); jTextField1.setText(""); jTextField1.setEditable(true); jTextField2.setText(""); jTextField2.setEditable(false); jLabel2.setText(""); monthrain = 0; sum = 0; monthcount = 1; counter = 0; counter2 = 0; } else if(counter2 == 0){ jTextArea1.setText("Invalid years\nTry again"); jTextField1.setText(""); jTextField1.setEditable(true); jTextField2.setText(""); jTextField2.setEditable(false); monthrain = 0; sum = 0; monthcount = 1; counter = 0; counter2 = 0; } }

Alright, so the assignment is:

Create a GUI application with Netbeans that uses nested loops to collect data and calculate the average rainfall over a period of years. First the program should ask for 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, 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.

On my GUI, I have 2 textfields, 2 jlabels, 1 textarea, and 1 jbutton. When I enter 1 as the number of years I wanted and enter in values for month, it only loops 11 times and only added values for 11 months and displayed it. But, if I enter 2 as the number of years I wanted, it loops through all 12 months for the first year, but the second year, it only loops 11 times, same as if I were to put 1 as the number of years I wanted. So basically, it will only ask me values for 11 month for the last year. I thought adding in "i == 12" would fix it, but it didn't. Helpppp, I've been stuck on this for the past 2 hours and my head is HURTING!