================
cOdiNG meNU jaVa
================ import javax.swing.*;
public class Program1{
public static void main(String [] args){
Program1 Menu = new Program1();
}
public Program1(){
int pil;
pil = Integer.parseInt(JOptionPane.showInputDialog("===Menu=== \n 1.Biodata \n 2.Persegi \n 3.Deret \n 4.ext \n\n Masukkan Pilihan Anda [1..4]" ));
switch(pil){
case 1 :
String nama, npm, kelas;
nama = JOptionPane.showInputDialog("Masukkan Nama Anda : ");
npm = JOptionPane.showInputDialog("Masukkan NPM Anda :");
kelas = JOptionPane.showInputDialog("Masukkan Kelas Anda :");
String biodata ="Nama anda :"+nama+"\n NPM anda :"+npm+"\n KELAS anda :"+kelas;
JOptionPane.showMessageDialog(null,biodata);
break;
case 2 :
String VarSisi = JOptionPane.showInputDialog("Masukkan nilai sisi = ");
int Sisi = Integer.parseInt (VarSisi);
int luas = Sisi*Sisi;
String persegi = "Luas Persegi "+Sisi+" x "+Sisi+" = "+luas;
JOptionPane.showMessageDialog(null,persegi);
break ;
case 3 :
String VarDeret = JOptionPane.showInputDialog("Masukkan Tinggi = ");
int deret = Integer.parseInt(VarDeret);
for (int i=1 ; i<=deret; i++);
{ for(int j=1; j<=i; j++);
{ System.out.print ("*");
}
System.out.println(" ");
}
break;
case 4 :
JOptionPane.showMessageDialog(null,"Terima Kasih","Silahkan keluar",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
break;
default:
JOptionPane.showMessageDialog(null,"Inputan hanya 1..4","Salah Input!",JOptionPane.WARNING_MESSAGE);
}
}
}
0 komentar:
Posting Komentar