Sunday, April 5, 2015

Menggunakan Perintah Switch pada NetBeans





Code Program Proses :

 private void eprosesActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        int a;
        String b;
        a=Integer.parseInt(ebil.getText());
        switch(a){
            case 1:b="Pilihan Pertama";
               eket.setText(""+b);
               break;
            case 2:b="Pilihan Kedua";
                eket.setText(""+b);
                break;
            case 3:b="Pilihan Ketiga";
                eket.setText(""+b);
                break;
            case 4:b="Pilihan Keempat";
                eket.setText(""+b);
                break;
            case 5:b="Pilihan Kelima";
                eket.setText(""+b);
                break;
            default:b="Pilihan Default";
                eket.setText(""+b);
                break;
        }
    }                                      

    private void ebatalActionPerformed(java.awt.event.ActionEvent evt) {                                      
        // TODO add your handling code here:
        ebil.setText("");
        eket.setText("");
       
    }                                     

Menggunakan If Lebih dari dua Kondisi pada NetBeans






Code Program Proses :

 private void bprosesActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        String a,b = new String ();
        float c,d,e,f,g;
        a=enim.getText();
        b=enama.getText();
        c=Float.parseFloat(eniab.getText());
        d=Float.parseFloat(enitu.getText());
        e=Float.parseFloat(eniuts.getText());
        f=Float.parseFloat(eniuas.getText());
        g=(c*10/100)+(d*20/100)+(e*30/100)+(f*40/100);
        if((g>=80)&&(g<=100)){
        enian.setText(""+g);
        enihu.setText("A");
        eket.setText("SANGAT MEMUASKAN");
        }
        else if((g>=70)&&(g<=79)){
            enian.setText(""+g);
        enihu.setText("B");
        eket.setText("MEMUASKAN");
        }    
        else if((g>=60)&&(g<=69)){
            enian.setText(""+g);
        enihu.setText("C");
        eket.setText("CUKUP");
        }
        else if((g>=50)&&(g<=59)){
            enian.setText(""+g);
        enihu.setText("D");
        eket.setText("KURANG");
        }
        else if((g>=80)&&(g<=100)){
        enian.setText(""+g);
            enihu.setText("E");
        eket.setText("SANGAT KURANG");
        }
    }                      

Mengenal Password Field dan Perintah If Sederhana pada NetBeans


Code Program Proses

private void bProsesActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        int a;
        String b;
        a=Integer.parseInt(eNilai.getText());
        if(a>60){
            b="LULUS";
            eKet.setText(""+b);
        }
        else{
            b="MENGULANG";
            eKet.setText(""+b);        
        }
       
    }                

Sunday, March 29, 2015

Mengenal cara mendeklarasikan variabel dan mengkonvensi variabel

Form Aritmatika 



CODE PROGRAMNYA :


"C" :

private void bCActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        ebil1.setText("");
        ebil2.setText("");
        eHasil.setText("");
        ebil1.requestFocus();
    }                                 


"MAX" :
    

private void bMaxActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
        int a,b;
        a=Integer.parseInt(ebil1.getText());
        b=Integer.parseInt(ebil2.getText());
        if (a>b){
            eHasil.setText(Integer.toString(a));
        }
        else{
            eHasil.setText(Integer.toString(b));
        }
    }                                   

"MIN" :

    private void bMinActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
        int a,b;
        a=Integer.parseInt(ebil1.getText());
        b=Integer.parseInt(ebil2.getText());
        if (a<b){
            eHasil.setText(Integer.toString(a));
        }
        else{
            eHasil.setText(Integer.toString(b));}
    }   

                               
"EXIT" :

    private void bExitActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        dispose();
    }                
                   

Operator "+" :

    private void bpActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        int a, b, c;
        a=Integer.parseInt(ebil1.getText());
        b=Integer.parseInt(ebil2.getText());
        c=a+b;
        eHasil.setText(Integer.toString(c));
    }                                 

Operator " - " :

    private void bmActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        int a, b, c;
        a=Integer.parseInt(ebil1.getText());
        b=Integer.parseInt(ebil2.getText());
        c=a-b;
        eHasil.setText(Integer.toString(c));
    }               
                 
Operator " / " :

    private void bbActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        int a, b, c;
        a=Integer.parseInt(ebil1.getText());
        b=Integer.parseInt(ebil2.getText());
        c=a/b;
        eHasil.setText(Integer.toString(c));
    }                                 

Operator " * " :

    private void bkActionPerformed(java.awt.event.ActionEvent evt) {                                  
        // TODO add your handling code here:
        int a, b, c;
        a=Integer.parseInt(ebil1.getText());
        b=Integer.parseInt(ebil2.getText());
        c=a*b;
        eHasil.setText(Integer.toString(c));
    }                                 

Mengenal Label, Textfield dan Button pada NetBeans


Form mahasiswa yang menampilkan NIM, NAMA, ALAMAT dan NO TELP









Kode Program

CLEAR :

 private void bCLEARActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        eNIM.setText("");
        eNAMA.setText("");
        ealamat.setText("");
        eno.setText("");
    }             

EXIT:

private void bEXITActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        dispose();

Saturday, June 21, 2014

STACK

<html>
<head>
<script type=text/javascript>
{
var stack=[];
var queue=[];

function input_stack(data)
{
stack.push(data);
}

function tampil_stack(list)
{
//alert("ok")
list.options.length=0;
for (var i=0; i<stack.length; i++)
{
var data=new Option (stack[i]);
list.options[list.options.length]=data;
}
}

function ambil_stack()
{
var x=stack.pop();
queue.unshift(x);
}

function tampil_queue(combo)
{
combo.options.length=0;
for (var j=0; j<queue.length;j++)
{
var y = new Option (queue[j]);
combo.options[combo.options.length]=y;
}
}

function ambil_queue()
{
var z=queue.pop();
if (z==undefined)
alert("sudah kosong")
else
return z;
}

}


</script>
</head>
<body bgcolor=red>

<input type=text id=awal>

<input type=button value=masuk onclick='input_stack(awal.value);awal.value="";tampil_stack(listStack);'>

<select id="listStack" size=5>
<option> stack </option>
</select>

<input type=button value=keluar onclick='ambil_stack();tampil_queue(listQueue);tampil_stack(listStack);'>

<select id="listQueue" size=5>
<option> queue </option>
</select>

<input type=button value=hasil onclick='akhir.value=ambil_queue();tampil_queue(listQueue);'>
<input type=text id=akhir>
</body>
</html>