Minggu, 21 Agustus 2011

contoh program java input data

SOURCH KODE:

    import java.util.Scanner;
   
    class mhs{
        public static void main(String[] args)
        {
            Scanner scansod = new Scanner(System.in);
   
           
            System.out.print("Nim               : "); String nim = scansod.nextLine();
            System.out.print("Nama              : "); String nama = scansod.nextLine();
                System.out.print("Matakuliah        : "); String matkul = scansod.nextLine();
            System.out.print("Absen        : "); double absen = scansod.nextDouble();
            System.out.print("Tugas        : "); double tugas = scansod.nextDouble();
            System.out.print("Uts          : "); double uts = scansod.nextDouble();
            System.out.print("Uas          : "); double uas = scansod.nextDouble();
            System.out.println("--------------------------------------");
            if(absen > 10) absen=10;
            else absen=0;
            double NA;
                NA=absen+(0.3*tugas)+(0.3*uts)+(0.3*uas);
      
            System.out.println("Nim                : "+nim);
            System.out.println("Nama               : "+nama);
                System.out.println("Mata Kuliah        : "+matkul);
            System.out.println("Absen              : "+absen);
            System.out.println("Tugas              : "+tugas);
            System.out.println("Uts                : "+uts);
            System.out.println("Uas                : "+uas);
            System.out.println("Nilai Akhir        : "+NA);
               
            if(NA>=80)System.out.println("Grade        : A");
            else if(NA<80 && NA >=60)System.out.println("Grade        : B");
            else if(NA<60 && NA >=40)System.out.println("Grade        : C");
            else if(NA<40 && NA >=20)System.out.println("Grade        : D");
            else if(NA<20)System.out.print("Grade        : E");
        }
    }

HASIL OUTPUT:


2 komentar:

  1. Dear marni....
    i love you so much... hihihiih
    makasih yaaa.. berkat postingan mu ini, tugas kedua ku sukses...hihihihihh....
    salam kenal... :)
    add me :
    http://fb.me/vnine

    BalasHapus
  2. Nice share, untuk contoh program input lainnya bisa kunjungi :

    http://top-ilmu.blogspot.com/2012/10/contoh-program-input-pada-java.html

    Kunjungi balik ya sist. Thx. :)

    BalasHapus