Hi all,
I really need your help on this as I am just learning Java. I do have an error message which says "cannot find symbol on line 23.
Many thanks.
import javax.swing.JOptionPane;
public class averageRainfall {
public static void main(String[] args) {
//declare variables
String[] Month = new String[6];
int[] Rainfall = new int[6];
//for loop to work through the array
for (int i = 0; i < 6; i++) {
Month[i] = JOptionPane.showInputDialog(null, "Please enter the name of the month you want to enter the rainfall for");
Rainfall[i] = Integer.parseInt(JOptionPane.showInputDialog(null, "Please enter the amount of rainfall in centimetres for each month"));
}
averageCalculation(Month, Rainfall);
//print average rainfall per month for the six month period
JOptionPane.showMessageDialog(null, "The average of rainfall is " + average + " centimetres per month");
System.exit(0);
}
public static int averageCalculation(String Month[], int Rainfall[]) {
int total = 0;
//calculate average
for (int i = 0; i < Rainfall.length; i++) {
total += Rainfall[i];
}
int average = total / 6;
//return result
return average;
}
}