Kamis, 24 Oktober 2013

Fourth Duty On PBO


1. Mencari Luas dan Keliling Segitiga

package egyjava;
public class sgitiga extends javax.swing.JFrame {
    float als,tinggi,ls,kl;
    public sgitiga() {
        initComponents();
    }

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        als = Float.parseFloat(jTextField1.getText());
        tinggi = Float.parseFloat(jTextField2.getText());
       
        ls = (float) 0.5 * (als*tinggi);
        jTextField3.setText(String.valueOf(ls));
       
        kl = (float) 3* als;
        jTextField4.setText(String.valueOf(kl));
    } 
}

// hasil :




 2. Mencari Luas dan Keliling Persegi Panjang

package egyjava;
public class pp extends javax.swing.JFrame {
    int pjg,lbr,ls,kl;
    public pp() {
        initComponents();
    }

 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        pjg = Integer.parseInt(jTextField1.getText());
        lbr = Integer.parseInt(jTextField2.getText());
       
        ls = pjg*lbr;
        jTextField3.setText(String.valueOf(ls));
       
        kl = 2*(pjg+lbr);
        jTextField4.setText(String.valueOf(kl));
    } 
}

// hasil :              


3. Mencari Luas dan Keliling Lingkaran

package egyjava;
public class lingkar extends javax.swing.JFrame {
    float r,ls,kl;
    public lingkar() {
        initComponents();
    }


 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
        // TODO add your handling code here:
        r = Float.parseFloat(jTextField1.getText());
        v = (float) 3.14;
       
        ls = v*(r*r);
        jTextField3.setText(String.valueOf(ls));
       
        kl = 2*(v*r);
        jTextField4.setText(String.valueOf(kl));
    } 
}                   

// hasil :





Tidak ada komentar:

Posting Komentar