Respuesta :
The program is an illustration of conditional statements and loops.
- Conditional statements are used to make decisons
- Loops are used for iterative purposes
The main program.
The program written in Java, where comments are used to explain each action is as follows:
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//This declares the array
double rainfall[] = new double[12];
//This initializes the total amount of rainfall
double total = 0;
//This gets input for the array
for(int i = 0; i < 11; i++){
rainfall[i] = input.nextDouble();
total+=rainfall[i];
}
//This initializes the smallest and the largest amount of rainfall
double largest = 0; double smallest = 0;
int smallestMonth = 0; int largestMonth = 0;
for(int i=1; i< 12; i++){
//This determines the largest amount of rainfall
if(rainfall[i] > largest){ largestMonth = i; largest = rainfall[i]; }
//This determines the smallest amount of rainfall
else if (rainfall[i] < smallest){ smallestMonth = i; smallest = rainfall[i]; }
}
//This initializes the months
String months[] = new String[]{"January","February","March","April","May","June","August","September","October","November","December"};
//This prints the required output
System.out.println("The average is: " + total/12+", month with largest - "+months[largestMonth]+", month with lowest - "+months[smallestMonth]);
}
}
Read more about conditional statements and loops at:
https://brainly.com/question/24833629