Rabu, 31 Oktober 2012

java if-else

public class logika {
                public static void main (String[] args){
                                float  nk = 85;
                                float  nm = 85;
                                float  nt = 80;
                                float nu = 85;
                                String ket;
                                float nr = (nk+nt+nm+nu)/4;
                               
                                if (nr>90){
                                                ket = "Lulus Memuaskan";
                                }
                                else{
                                                if ((nr>81)&&(nr<91)){
                                                                ket = "Lulus Baik";
                                                }
                                                else{
                                                                if ((nr>71)&&(nr<82)){
                                                                                ket = "Lulus Cukup";
                                                                }
                                                                else{ ket = "Tidak Lulus";
                                                                }
                                                }
                                }
                                System.out.println("Nilai Kehadiran = "+nk);
                                System.out.println("Nilai MID = "+nm);
                                System.out.println("Nilai Tugas = "+nt);
                                System.out.println("Nilai Utama = "+nu);
                                System.out.println("Nilai Rata Rata = "+nr);
                                System.out.println("Keterangan = "+ket);
                }
}

Output : 



Tidak ada komentar:

Posting Komentar