Thursday, June 6, 2013

Program Nilai Akhir

Source Code :

import javax.swing.JOptionPane;
public class NilaiAkhir {

    public NilaiAkhir() {
    }
    
    public static void main (String [] args) throws NullPointerException, Exception{

final int MAX = 5;
int i = 0;
int hasil;
char huruf;
String ket;

int [] uas = new int [MAX];
int [] uts = new int [MAX];
int [] tugas = new int [MAX];
String [] nama  = new String [MAX];
String [] nim  = new String [MAX];
String ulang = null;

do{
nim[i] = JOptionPane.showInputDialog ("MASUKKAN NIM : ");
nama[i] = JOptionPane.showInputDialog ("MASUKKAN NAMA : ");
tugas[i] = Integer.parseInt(JOptionPane.showInputDialog("MASUKKAN NILAI TUGAS :"));
uts[i] = Integer.parseInt(JOptionPane.showInputDialog("MASUKKAN NILAI UTS :"));
uas[i] = Integer.parseInt(JOptionPane.showInputDialog("MASUKKAN NILAI UAS :"));

i++;

if(i < MAX)
ulang = JOptionPane.showInputDialog ("MAU MENAMBAH DATA LAGI [Y/T] :");
else
ulang = "T";

}while(ulang.toUpperCase().equals("Y"));

System.out.println("No\tNIM\t\tNAMA\t\tTUGAS\tUTS\tUAS\tNILAI\tHURUF\tKETERANGAN");
for(int j = 0; j < i; j++){
hasil = (tugas[j] + uts[j] + uas[j]) / 3;

if(hasil >= 85)
huruf = 'A';
else if(hasil >= 75)
huruf = 'B';
else if(hasil >= 65)
huruf = 'C';
else if(hasil >= 50)
huruf = 'D';
else
huruf = 'E';

switch(huruf){
case 'A':
case 'B':
case 'C': ket = "Lulus"; break;
default : ket = "Tidak lulus";
}

System.out.print(""+ (j + 1));
System.out.print("\t"+ nim[j]);
System.out.print("\t"+ nama[j]);
System.out.print("\t\t"+ tugas[j]);
System.out.print("\t"+ uts[j]);
System.out.print("\t"+ uas[j]);
System.out.print("\t"+ hasil);
System.out.print("\t"+ huruf);
System.out.print("\t"+ ket);
System.out.println();
}
}
}


Outputnya :


0 comments:

Post a Comment