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 :
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