Saturday, 17 November 2012

Contoh Array sederhana Di java



package Perintah_array;
import java.util.*;

public class Array_3 {

    public static void main(String[] args) {
       Scanner input = new Scanner(System.in);
       String nama []= new String[2];
       double nuts [] =new double[2];
       double nuas [] =new double[2];
       double nrata [] =new double[2];

       int i, a=1;
       for (i=0;i<2;i++)
       {
           System.out.print("Nama Mahasiswa ke -"+a+"=");
           nama[i]=input.next();
           System.out.print("Nilai UTS =");
           nuts[i]=input.nextDouble();
            System.out.print("Nilai Uas =");
            nuas[i]=input.nextDouble();
            nrata[i]=(nuts[i]+nuas[i])/2;
            System.out.println("Nilai Rata-rata "+nama[i]+"="+nrata[i]+"\n");
            ++a;


       }


    }

}


Perhatian: Yuk Baca Artikel bagus di Nurul Musthofa

Artikel Terkait

No comments:

Post a Comment

 

Network

Pesan

Semoga situs ini bermanfaat