New Entri

Senin, 24 Mei 2010

Java " Case "

import javax.swing.*;
public class STMIK
{
public static void main (String[]args)
{
String Pil="";
String hasil ="";
String input = "";
String input2 = "";
String input3 = "";
String input4 = "";



int Menu=0;

int nm = 0;
int jr = 0;
int an =0;
int tg =0;
int md=0;
int fn=0;
int qs=0;
double rt=0;




Pil = JOptionPane.showInputDialog ("Pilihan : "+
"\n1. Biodata"+" \n2. IP");

Menu = Integer.parseInt (Pil);
switch (Menu)

{
case 1:
input = JOptionPane.showInputDialog ("Biodata"+"\nInput nama : ");
input2 = JOptionPane.showInputDialog ("Input jurusan : ");
input3 = JOptionPane.showInputDialog ("Input angkatan : ");
hasil +="\nNama =" +(input);
hasil +="\nJurusan =" +(input2);
hasil +="\nAngkatan =" +(input3);
break ;

case 2:
input = JOptionPane.showInputDialog ("indeks prestasi"+"\nInput Nilai Tugas : ");
input2 = JOptionPane.showInputDialog ("Input Nilai Mid : ");
input3 = JOptionPane.showInputDialog ("Input Nilai Final : ");
input4 = JOptionPane.showInputDialog ("Input Nilai Quis : ");
tg =Integer.parseInt(input);
md =Integer.parseInt(input2);
fn =Integer.parseInt(input3);
qs =Integer.parseInt(input4);
hasil +="\nN Tugas =" +Integer.toString(tg);
hasil +="\nN Mid =" +Integer.toString(md);
hasil +="\nN Final =" +Integer.toString(fn);
hasil +="\nN Quis =" +Integer.toString(qs);
rt +=(tg+md+fn+qs)/4;
hasil +="\nRata rata =" +Double.toString(rt)+"\n";
if (rt >50 )
hasil +="Nilai rata-rata anda :" + (rt) + "\nLulus";
else
hasil +="Nilai rata-rata anda = " + (rt) + "\nTidak Lulus";
break;

default:
hasil = "Maaf,, Angka Yang Ada Input Tidak Ada Dalam Pilihan !!!";
}
JOptionPane.showMessageDialog (null, hasil);
System.exit(0);
}
}

0 komentar:

Posting Komentar