Sunday, April 5, 2015

Menggunakan Perintah Perulangan While pada NetBeans

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

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());
        while (b<=50) {
            areahasil.append(b+".Kharisma"+"\n");
            b=b+10;
        }
       
    }                 

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


 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());
        while(b>=0){
            areahasil.append(b+""+"\n");
            b=b-3;
        }
    }                                    


 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;
        while (a<=3){
            b=1;
            while (b<=3){
                areahasil.append(a+"   "+c +"\n");
                b++;
            }
            a++;
            c=c-1;
        }
    }                                    

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());
        while(b<=a){
            areahasil.append(b+""+"\n");
            jum=jum+b;
            b++;
        }
       
        areahasil.append("___+"+"\n");
        areahasil.append(jum+"\n");
    }     

0 comments:

Post a Comment