Sourcode :
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class RataRata {
public static void main(String args[]) {
final int JUMLAH_DATA = 10;
int[] data = new int[JUMLAH_DATA];
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
for(int i = 0; i < JUMLAH_DATA; i++) {
System.out.print("data ke - " + i + " : ");
try {
String dtStr = bf.readLine();
data[i] = Integer.parseInt(dtStr);
} catch(IOException e) {
System.out.print(e);
}
}
System.out.println("----------------------------------------------");
System.out.print("Data acak : ");
int jumlah = 0;
for(int i = 0; i < JUMLAH_DATA; i++) {
System.out.print(data[i] + ", ");
jumlah += data[i];
}
float rata2 = jumlah / JUMLAH_DATA;
System.out.println("\n---------------------------------------------");
System.out.println("Rata - rata = " + rata2);
}
}
Outputnya :
Monday, April 1, 2013
Mencari Nilai Rata - Rata
Silahkan Copas Gannnn,,,,
Tapi Tolong Jangan Lupa Komentarnya yy gann,,,
0 comments:
:)) :)] ;)) ;;) :D ;) :p :(( :) :( :X =(( :-o :-/ :-* :| 8-} ~x( :-t b-( :-L x( =))
Post a Comment