Mei 26, 2013

Bintang


import java.util.Scanner;
public class Bilangan{
public static void main(String[] args){
Scanner bilangan = new Scanner(System.in);
int data[]={1,2,4,7,9,2,5,4,7,9};
int nilai;
int a,b,c,d,e;
double total=0, rata;
System.out.print("Masukkan Banyak data : ");
nilai = bilangan.nextInt();
for(int i=0; i<nilai; i++)
System.out.println("Data ke-"+ i +" = " + data[i]);
System.out.print("\n");
for(int i=0; i<nilai; i++)
total += data[i];
rata = total / nilai;
System.out.println("Total : "+ total);
System.out.println("Rata-rata : "+ rata);
System.out.println("Banyak Angka : ");
for(a=0; a<nilai; a++){
b=0;
for(c=0; c<nilai; c++){
if(data[c]==data[a]){
b++;
}
}
e=0;
for(d=0; d<=a; d++){
if(data[d]==data[a]){
e++;
}
}
if(e==1)
System.out.println(data[a]+"="+ b);

}
}
}

0 comments:

© 2011 Battle Of My Life, AllRightsReserved.

Designed by ScreenWritersArena