Dosen Pengampu : Fince Tinus Waruwu,M.Kom
Koding Program NetNeans
Menggunakan Fungsi If Jamak pada JOptionPane
package tugas.agung.lestari.joptionpane;
import javax.swing.JOptionPane;
public class TugasAgungLestariJOptionPane {
public static void main(String[] args) {
// TODO code application logic here
int x;
x = Integer.parseInt (JOptionPane.showInputDialog("Input NPM"));
String nama = "";
if (x == 15110672) {
nama = "Agung Lestari";
} else if (x == 15118998){
nama = "Andy Ryan";
} else if (x == 15113322){
nama = "Teguh Saputra";
} else if (x == 15111122){
nama = "Sutejo Tukimin";
}else if (x == 15110022){
nama = "Surti Safitri";
}
String jenjang = JOptionPane.showInputDialog ("Input Jenjang");
String Jurusan = "";
if (jenjang.equals("S1")){
Jurusan = "Teknik Informatika";
} else if (jenjang.equals("D3")){
Jurusan = "Manajemen Informatika";
}
String konsentrasi = JOptionPane.showInputDialog ("Konsentrasi");
int nh;
nh = Integer.parseInt (JOptionPane.showInputDialog("Input Nilai Hadir"));
double nilai_hadir ;
nilai_hadir = 0.1 * nh ;
int ng ;
ng = Integer.parseInt (JOptionPane.showInputDialog("Input Nilai Tugas"));
double nilai_tugas ;
nilai_tugas = 0.2 * ng ;
int nt;
nt = Integer.parseInt (JOptionPane.showInputDialog("Input Nilai UTS"));
double nilai_uts ;
nilai_uts = 0.3 * nt;
int na;
na = Integer.parseInt (JOptionPane.showInputDialog("Input Nilai UAS"));
double nilai_uas ;
nilai_uas = 0.4 * na;
double total_nilai = nilai_hadir + nilai_tugas + nilai_uts + nilai_uas;
String Nilai_Huruf = "";
if (total_nilai > 85) {
Nilai_Huruf = " A ";
} else if (total_nilai > 80 ) {
Nilai_Huruf = "B+";
} else if (total_nilai > 75 ) {
Nilai_Huruf = "B";
} else if (total_nilai > 70 ) {
Nilai_Huruf = "C+";
}else if (total_nilai > 65 ) {
Nilai_Huruf = "C";
}else if (total_nilai > 60 ) {
Nilai_Huruf = "D";
} else if (total_nilai < 60 ) {
Nilai_Huruf = "E";
}
JOptionPane.showMessageDialog(null,"NPM = " +x+"\n"+"Nama = "+nama+"\n"
+"Jenjang = "+jenjang+"\n"
+"Jurusan = "+Jurusan+"\n"
+"Konsentrasi = "+konsentrasi+"\n"
+"Nilai Hadir = "+nilai_hadir+"\n"
+"Nilai Tugas = "+nilai_tugas
+"\n"+"Nilai UTS = "+nilai_uts+"\n"
+"Nilai UAS = "+nilai_uas+"\n"
+"Total Nilai = "+total_nilai+"\n"
+"Nilai Huruf = "+Nilai_Huruf+"\n");
}
}
Maka akan tampil seperti gambar di bawah ini :
Gambar 1. Kotak Dialog Input NPM
Gambar 2. Kotak Dialog Input Jenjang
Gambar 3. Kotak Dialog Input Konsentrasi
Gambar 4. Kotak Dialog Input Nilai Hadir
Gambar 5. Kotak Dialog Input Nilai Tugas
Gambar 6. Kotak Dialog Input Nilai UTS
Gambar 7. Kotak Dialog Input Nilai UAS
Gambar 8. Kotak Dialog Output Message