Jumat, 21 Oktober 2011

Larik

import java.util.Scanner;
public class Larik1
{
public static void main(String args[])
{
Scanner masuk=new Scanner(System.in);
float nilai[]=new float[5];
float total, rata;
System.out.println("Masukan 5 buah data nilai");
  for(int i=0;i<5;i++){
  System.out.print("Data ke"+(i+1)+":");
  total=0;
  for(int i = 0;i<5;i++)
total = total + nilai[i];
for(int i = 0;i<5;i++)
rata = total/5;

  nilai[i]=masuk.nextFloat();
  }
  System.out.println("data nilai yang dimasukan");
  for(int i = 0;i<5;i++)
     System.out.println(nilai[i]);

  }
}

Tidak ada komentar:

Posting Komentar