This is what I've done so far; I was able to calculate the average, but I'm not sure how to find the median. I also know that I need to sort the array to make it easier.
public class SAA {
public static void main(String[] args) {
int[] num = {60, 70, 82, 1216, 57, 82, 34, 560, 91, 86};
int total = 0;
for (int i = 0; i < num.length; i++) {
if ((num[i] > 0) && (num[i] < 100)) {
total += num[i];
}
}
System.out.println(total / 10);
}
}
This is my attempt at using bubble sort:
public class Bubblesort {
public static void main(String[] args) {
int[] num = {60, 70, 82, 1216, 57, 82, 34, 560, 91, 86};
int temp = 0;
int[] add = new int[num.length + 1];
for (int i = 0; i < num.length; i++) {
for (int j = i + 1; j < num.length; j++) {
if (num[i] > num[j]) {
temp = num[i];
num[i] = num[j];
num[j] = temp;
}
}
}
for (int i = 0; i < num.length; i++) {
System.out.print(num[i] + " ");
}
}
}