Jumat, 30 Desember 2011

tugas algoritma modul 8

import java.util.Scanner;

public class Modul7

{
public static void main(String args[])

{
Scanner masuk=new Scanner(System.in);

int i=1;

float n, jum, x, rata;

System.out.println("Banyaknya data: ");

n = masuk.nextFloat();

jum=0;

while (i<=n) {

                System.out.println("Data ke-"+i+": ");
                x=masuk.nextFloat();
                jum += x;
                i++;

}
rata = jum / n;
System.out.println("Rata-rata: "+rata);

System.out.println("Jumlah: "+jum);
}
}

0 komentar:

Posting Komentar

Statistik

Translate

Blog Archive