package com.ahmad.apandi;
import java.util.Scanner;
import java.util.stream.IntStream;
public class Main {
public static void main(String[] args) {
// write your code here Scanner input = new Scanner(System.in);
int maxValueKu=0,minValueKu=0,jumalKu,meanOlympicKu,jumlahAngkaKu = 0;
int array[] = new int[10];
System.out.println("Masukan angka lalu enter ulangi sampai 10 kali.");
for (int i = 0; i < array.length; i++) {
int next = input.nextInt();
jumlahAngkaKu=i;
if (i == 10) {
break;
}
array[i] = next;
}
// get nilai terbesar maxValueKu = Main.getMaxValue(array);
// get nilai terkecil minValueKu= Main.getMinValue(array);
System.out.println("Nilai yang anda masukan.");
printArray(array);
jumalKu= IntStream.of(array).sum();
meanOlympicKu = (jumalKu-minValueKu-maxValueKu)/(jumlahAngkaKu-2);
System.out.println("Nilai Mean Olympic adalah = "+meanOlympicKu);
}
// get nilai terbesar public static int getMaxValue(int[] array) {
int maxValue = array[0];
for (int i = 1; i < array.length; i++) {
if (array[i] > maxValue) {
maxValue = array[i];
}
}
return maxValue;
}
// get nilai terkecil public static int getMinValue(int[] array) {
int minValue = array[0];
for (int i = 1; i < array.length; i++) {
if (array[i] < minValue) {
minValue = array[i];
}
}
return minValue;
}
//this method prints the elements in an array...... //if this case is true, then that's enough to prove to you that the user input has //been stored in an array!!!!!!! public static void printArray(int arr[]) {
int n = arr.length;
for (int i = 0; i < n; i++) {
System.out.print(arr[i] + " ");
}
}
}
Comments