New Entri

Senin, 24 Mei 2010

Java " Case & If "


import javax.swing.JOptionPane;
public class Mid_Semester
{
public static void main(String[]args)
{
String hasil="";
String nama="";
String juru="";
String msg="";
String ipk1="";
double ipk=0;

int ips=0;
int spp =0;
int bpp=0;
int jur=0;
int total=0;

String pilihan=JOptionPane.showInputDialog("Pilihan :\n1. Data Mahasiswa\n2. Predikat Kelulusan\n");
int menu=Integer.parseInt(pilihan);

switch (menu)
{
case 1:
nama= JOptionPane.showInputDialog("Nama : ");
hasil +="Nama Mahasiswa : "+(nama)+"\n";
String piljur=JOptionPane.showInputDialog("Pilih Jurusan :\n1.Teknik Informatika\n2.Sistem Komputer\n3. Manajemn Komputer\n4. Komputer Akuntansi");
jur=Integer.parseInt(piljur);
switch (jur)
{
case 1:
juru="Teknik Informatika";
spp=800000;
bpp=1200000;
total=spp+bpp;
hasil +="Jurusan : "+(juru)+"\n";
hasil +="SPP : "+(spp)+"\n";
hasil +="BPP : "+(bpp)+"\n";
hasil +="Total Biaya : "+Integer.toString(total);
break;
case 2:
juru="Sistem Informatika";
spp=700000;
bpp=1250000;
total=spp+bpp;
hasil +="Jurusan : "+(juru)+"\n";
hasil +="SPP : "+(spp)+"\n";
hasil +="BPP : "+(bpp)+"\n";
hasil +="Total Biaya : "+Integer.toString(total);
break;
case 3:
juru="Manajemen Informatika";
spp=600000;
bpp=1100000;
total=spp+bpp;
hasil +="Jurusan : "+(juru)+"\n";
hasil +="SPP : "+(spp)+"\n";
hasil +="BPP : "+(bpp)+"\n";
hasil +="Total Biaya : "+Integer.toString(total);
break;
case 4:
juru="Teknik Informatika";
spp=550000;
bpp=1000000;
total=spp+bpp;
hasil +="Jurusan : "+(juru)+"\n";
hasil +="SPP : "+(spp)+"\n";
hasil +="BPP : "+(bpp)+"\n";
hasil +="Total Biaya : "+Integer.toString(total);
break;
default:hasil+=("Pilihanya Salah");
}
break;
case 2:
nama= JOptionPane.showInputDialog("Nama Mahasiswa : ");
hasil +="Nama Mahasiswa : "+(nama)+"\n";
ipk1 = JOptionPane.showInputDialog("IPK : ");
ipk = Double.parseDouble(ipk1);
hasil +="IPK :"+(ipk)+"\n";

if (ipk >=3.50)
hasil +="Pujian";
else if ((ipk < 3.50 ) && (ipk >= 3.00))
hasil +="sangat memuaskan";
else if ((ipk < 3.00) && (ipk >=2.50))
hasil +="cukup";
else if ((ipk < 2.50) && (ipk >= 2.00))
hasil +="kurang";
else
hasil +="eror";
break;

default:hasil+=("Tidak Ada dalam Pilihan");

}
JOptionPane.showMessageDialog (null,hasil);
System.exit(0);
}
}

0 komentar:

Posting Komentar