Sunday, April 5, 2015

Menggunakan Perintah Perulangan For pada NetBeans



Code Program Proses :

private void bprosesActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        int a,b;
        a=Integer.parseInt(ebil.getText());
        for(b=1; b<=a; b++){
            areahasil.append(b+".Kharisma"+"\n");
        }
    }   


Code Program Latihan 1 :

private void blat1ActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
       
       
        int a,b;
        b=Integer.parseInt(ebil.getText());
        for (a=10; a<=50; a=a+10){
            areahasil.append(a+ ".Kharisma" +"\n");
        }
    }                                   


Code Program Latihan 2 :

  private void blat2ActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
        int a,b;
        a=Integer.parseInt(ebil.getText());
        for (b=5; b>0; b--){
            areahasil.append(b+""+"\n");
        }
    }     

Code Program Latihan  3 :
 
private void blat3ActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
        int a,b;
        b=Integer.parseInt(ebil.getText());
        for(a=9; a>=0; a=a-3){
            areahasil.append(a+""+"\n");
        }
    }    
 
 Code Program Latihan 4 :

private void blat4ActionPerformed(java.awt.event.ActionEvent evt) {                                    
        // TODO add your handling code here:
        int a,b,c,d;
        d=Integer.parseInt(ebil.getText());
        c=3;
        for(a=1; a<=3; a++){
            for(b=3; b>0; b--){
                areahasil.append(a+" "+c +"\n");
            }
        c=c-1;
        }
    }                  


 Code Program Latihan 5 :

private void blat5ActionPerformed(java.awt.event.ActionEvent evt) {                                     
        // TODO add your handling code here:
         int a,b;
        a=Integer.parseInt(ebil.getText());
        int jum=0;
        for (b=1; b<=a; b++){
            jum=jum+b;
            areahasil.append(b+"\n");
        }
        areahasil.append("___+\n");
        areahasil.append(jum+"\n");
    }                  

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();