Answer:
public static void display(int [] arr){
System.out.print("Arrays: ");
for(int i =0;i<arr.length;i++){
System.out.print(arr[i]+" ");
}
System.out.println();
}
public static void displayReverse (int [] arr){
System.out.print("Arrays in reverse order: ");
for(int i=arr.length-1;i>=0;i--){
System.out.print(arr[i]+" ");
}
System.out.println();
}
public static int displaySum (int [] arr){
System.out.print("Sum: ");
int sum = 0;
for(int i =0;i<arr.length;i++){
sum+=arr[i];
}
return sum;
}
public static void displayLessThan (int [] arr, int num){
System.out.print("Less than "+num+": ");
for(int i =0;i<arr.length;i++){
if(arr[i]<num){
System.out.print(arr[i]+" ");
}
}
System.out.println();
}
public static void displayHigherThanAverage (int [] arr){
System.out.print("Higher than average: ");
int sum = 0;
for(int i =0;i<arr.length;i++){
sum+=arr[i];
}
float average = sum/arr.length;
for(int i =0;i<arr.length;i++){
if(arr[i]>average){
System.out.print(arr[i]+" ");
}
}
System.out.println();
}
Explanation:
<em>The methods were written in Java. See attachment for explanation where I used comments to explain each lines.</em>
<em>Note that lines that begin with double slash (//) are comments</em>