public class mean_median {
public static void main(String[] args) {
int a[] = { 2, 34, 5, 67, 89, 34, 56, 6, 2 };
int len = a.length;
int median = 0;
System.out.println("The mean of the array is:");
int sum = 0;
for (int i = 0; i <= len - 1; i++) {
sum = sum + a[i];
}
int mean = sum / len;
System.out.println(mean);
for (int i = 0; i < len; i++) {
for (int j = i + 1; j < len; j++) {
if (a[i] > a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
for (int i = 0; i <= len; i++) {
if (len % 2 == 0) {
median = len / 2;
} else {
median = (len + 1) / 2;
}
}
System.out.println("Mediaqn is:" + a[median - 1]);
for (int i = 0; i < len; i++) {
for (int j = i + 1; j < len; j++) {
if (a[i] == a[j]) {
System.out.println("mode" + a[i]);
break;
}
}
}
}
package com.dain.logics;
public class mean_median { public static void main(String[] args) { int a[] = { 2, 34, 5, 67, 89, 34, 56, 6, 2 }; int len = a.length; int median = 0;
}