Sunday, April 5, 2015

Menggunakan Perintah Perulangan Do While pada NetBeans

Catatan dilatihan Input masukan yang menentukan SuperUser :

  
Code Program Proses :

private void bprosesActionPerformed(java.awt.event.ActionEvent evt) {                                       
        // TODO add your handling code here:
        // nilai var a ditentukan oleh pengguna:
        int a, b=1;
        a=Integer.parseInt(ebil.getText());
        do{
            areahasil.append(b+""+"\n");
            b++;
        }
        while(b<=a);
    }
   
Code Program Latihan 1 :

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

Code Program Latiha 2  :

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


Code Program Latihan 3  :

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


 Code Program Latihan 4  :

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


Code Program Latihan 5  :

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

 Code Program Batal :

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


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

0 comments:

Post a Comment