Statistik Java Jeliot

import jeliot.io.*;

public class Statistik {

public static int nilai_Maksimum(int data[]) {
    int maks = data[0];
    int n = data.length;
    int modus;
    
    for (int i=1; i<n; i++)
        if (maks < data[i]) { 
            maks = data[i];
            modus = i;        
        }
    System.out.println("Modusnya adalah " + modus);
    return maks;
}

public static void hitung_Frekuensi() {
     int data[] = {1,1,2,2,2,2,2,3,3,4,5,5,5,5};
     int i, n = data.length;     
     int [] f = new int[10];
     int nilai_terbesar;

     for (i=0; i<n; i++) ++f[data[i]];
     for (i=0; i<10; i++) 
         System.out.println("Data " + i + " sebanyak " + f[i]);
     nilai_terbesar = nilai_Maksimum(f);
     System.out.println("Dengan frekuensi = " + nilai_terbesar);
}

    public static void main() {
    hitung_Frekuensi();

    }
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s