There is a problem that I am trying to solve, but as a beginner it seems quite challenging. Here is the code I have written so far, however, when I run it only one window appears. Any advice or guidance would be greatly appreciated.
var years = prompt("Enter the number of years: "); // Number of years
var rainFall = new ArrayList();
while (years < 1) {
alert("Invalid. Enter 1 or greater: ");
years = prompt("Enter a year: ");
}
for (var y = 1; y <= years; y++) {
for (var m = 1; m <= NUM_MONTHS; m++) {
alert("Year " + y + ", month " + m + ": ");
monthRain = prompt("Enter rainfall for a month ");
rainfall.add(monthRain);
}
}
alert("\nNumber of months: " + (years * NUM_MONTHS) + "Total rainfall: " + calculateTotalRainfall(rainfall) + " inches" + "Average monthly rainfall: " + calculateAverageRainfall(rainfall) + " inches");