Rabu, 29 Februari 2012

Membuat Program Jumlah, Rata-rata, Nilai Maks dan Min pada Java Neatbeans

public class Main {
    public static void main(String[] args) {
        String nm = "Rudi Fitrianto",kls = "TI11D",nim = "11.11.2579";
        int nilai[] = {87,70,90,75,78};
        int max = 0,min = 100,i,rata,jml=0;
        for (i = 0; i < 5; i++)
        {
            jml=jml+nilai[i];
                      if (nilai[i] > max) {
                          max = nilai[i];
                      } else if (nilai[i] < min) {
                          min = nilai[i];
                      }
                 }
         rata=jml/i;
         System.out.println("Nama  : "+nm);
         System.out.println("Kelas : "+kls);
         System.out.println("NIM   : "+nim);
         System.out.println("\n87\t70\t90\t75\t78");
         System.out.println("\nJumlah \t: "+jml);
         System.out.println("Rata-rata      : "+rata);
                 System.out.println("Nilai Maksimum : " + max);
                 System.out.println("Nilai Minimun  : " + min);
    }
}