Jumat, 12 Oktober 2012

JAVA - Menghitung IPK


class PMG_0459 {
public static void main(String[] args) {
String nama = null;
String tmp = null;
String tmpMk = null;
int i = 0;

double nilai = 0;
double hasil = 0;

System.out.print("Namamu Bro : ");
nama = System.console().readLine();

for(i = 1; i < 6; i++) {
System.out.print("Masukan 2 SKS Mata Kuliah : ");
tmpMk = System.console().readLine();
System.out.print("Masukan Nilai : ");
tmp = System.console().readLine();

if(tmp.equals("A")) {
nilai = (2 * 4);
} else if(tmp.equals("B")) {
nilai = (2 * 3);
} else if(tmp.equals("C")) {
nilai = (2 * 2);
} else if(tmp.equals("D")) {
nilai = (2 * 1);
} else if(tmp.equals("E")) {
nilai = (2 * 0);
}

hasil = hasil + nilai;
}
hasil = hasil / 10;

System.out.println("\nNama : " + nama);
System.out.println("IPK   : " + hasil);
}
}

0 komentar:

Posting Komentar