Jumat, 30 Desember 2011

program menghitung rata rata

import java.util.Scanner;
public class DoWhile_Rata_rata
{
public static void main(String args[])
{
Scanner bil = new Scanner(System.in);
int p,q,r,s,t,rata;
r=0;
System.out.print("Masukan Banyak Bilangan : ");
p = bil.nextInt();
q=1;
do
{
System.out.print(q);
q++;
r+=q;

System.out.print(" ");
}

while (q<=p);
System.out.println();
System.out.println("================================");
System.out.println("jumlah : "+r);
System.out.println();
rata=q/p;
System.out.println("ratanya "+rata);

}
}

0 komentar:

Posting Komentar

Statistik

Translate

Blog Archive