Contoh Program aplikasi Java

Contoh Program aplikasi Java







/**
 * @(#)DemoFor3.java
 *
 *
 * @author
 * @version 1.00 2015/12/4
 */


public class DemoFor3 {

    public DemoFor3() {
    }
   
    public static void main(String[]args){
    int a,b,c,d,e,f;
    b=2;
    c=2;
    a= b+c;
    d= a+b;
    e= a*d;
    f= a/b;
    System.out.println("Nilai a = " + a);
    System.out.println("Nilai d = " + d);
    System.out.println("Nilai e = " + e);
    System.out.println("Nilai f = " + f);
    }
   
}




/**
 * @(#)DemoIFtigaKondisi2.java
 *
 *
 * @author
 * @version 1.00 2015/12/4
 */


public class DemoIFtigaKondisi2 {

    public DemoIFtigaKondisi2() {
    }
   
    public static void main(String[]args){
    char NilaiIndeks;
    double NilaiUTS,NilaiUAS,NilaiAkhir;
    //contoh data yang dimasukan
    NilaiUTS = 75.0;
    NilaiUAS = 60.0;
    NilaiIndeks = 'A';
    //menghitung nilai akhir menggunakan rumus di atas
    NilaiAkhir = (0.4 * NilaiUTS) + (0.6 * NilaiUAS);
    if(NilaiAkhir >= 80){
    NilaiIndeks = 'A';
    }else if(NilaiAkhir >= 70){
    NilaiIndeks = 'B';
    }else if(NilaiAkhir >= 50){
    NilaiIndeks = 'C';
    }else if(NilaiAkhir >= 30){
    NilaiIndeks = 'D';
    }else if(NilaiAkhir < 30){
    NilaiIndeks = 'E';
    }
    System.out.println("Nilai akhir \t:" + NilaiAkhir);
    System.out.println("Nilai indeks \t:" + NilaiIndeks);
   
    }
   
}

0 komentar: