belajar java part 3 pertemuan 5

import java.io.*;
class stati {
public static void main(String args[])throws IOException {
BufferedReader B=new BufferedReader (new InputStreamReader(System.in));
int arrInput []; arrInput = new int[100];
int arrUrut []; arrUrut = new int[100];
int inputCount=0;
int N;
int i, a, b, c, d, j, temp;
float jumlah;
float mean=0;
try {
System.out.print(“Masukkan banyaknya data : “);
N=Integer.parseInt (B.readLine());
System.out.println();
jumlah = 0;
try {
for (i=1; i<=N; i++) {
System.out.print("Masukkan data ke " + i + " : ");
arrInput[i]=Integer.parseInt (B.readLine());
jumlah = jumlah + arrInput[i];
arrUrut[i] = arrInput[i];
}
mean = jumlah/N;
for (a=1; a0 ) && (arrUrut[b]<arrUrut[b-1] )) {
temp = arrUrut[b];
arrUrut[b] = arrUrut[b-1];
arrUrut[b-1] = temp;
b–;
}
}
int Nm = N/2;
int median = arrUrut[(N+1)/2];
int Q1 = arrUrut[(median+1)/2];
int Q3 = arrUrut[(N+median)/2];
System.out.println("\nData terurut::");
for (i=1; i<=N; i++) {
System.out.print(" "+ arrUrut[i]);
}
System.out.println("\n");
System.out.println("Mean = " + mean);
System.out.println("Median = " + median);
System.out.println("Q1 = " + Q1);
System.out.println("Q3 = " + Q3);
} catch (IOException e) {
System.out.println ("Error!" +e);}
} catch (IOException e) {
System.out.println ("Error!" +e);}
System.exit(0);}}

simpan dengan stati.java

Iklan

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