import java.util.scaner.io.*; public class modus{ public static void main(String[]args){ int banyak; int data[]; int temp; int jumlah = 0; System.out.print("Banyaknya data : "); banyak =Input.nextInt(); data = new int[banyak]; for(int i=0;i<=banyak-1;i++){ System.out.print("Data ke-"+(i+1)+": "); data[i]=Input.nextInt(); } System.out.print("Data sudah diurut : "); for(int i=0; i<=banyak-1; i++) { System.out.print(data[i]+" "); jumlah=jumlah + data[i]; } int hasil=0; int besar=0; for (int i=0; i<data.length ;i++){ if(data[i]==banyak){ System.out.print(data[i]+" "); System.out.print(++temp); if(temp>besar){ besar=temp; hasil=banyak; } } else{ banyak=data[i]; temp=1; System.out.print(data[i]+" "); System.out.print(temp); } } System.out.print("Modus ="+hasil); } }
0 Response for the "Menentukan Modus dengan Jeliot"
Post a Comment