in my OOP class , mrs tita karlita teaching about make the simple calculator using java code .
public class hitung extends javax.swing.JFrame {
public hitung() {
initComponents();
}
@SuppressWarnings("unchecked")
private void kurangActionPerformed(java.awt.event.ActionEvent evt) {
}
private void bagiActionPerformed(java.awt.event.ActionEvent evt) {
}
private void tambahActionPerformed(java.awt.event.ActionEvent evt) {
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
double a , b ,hsil ;
a = Double.parseDouble(angka1.getText());
b = Double.parseDouble(angka2.getText());
if(tambah.isSelected() == true){
hsil = a + b;
hasil.setText(""+ hsil);
}
else if(kurang.isSelected() == true){
hsil = a - b;
hasil.setText(""+ hsil);
}
else if(kali.isSelected() == true){
hsil = a * b;
hasil.setText(""+ hsil);
}
else if(bagi.isSelected() == true){
hsil = a / b;
hasil.setText(""+ hsil);
}
}
private void angka2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new hitung().setVisible(true);
}
});
}
private javax.swing.JTextField angka1;
private javax.swing.JTextField angka2;
private javax.swing.JRadioButton bagi;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JLabel hasil;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JRadioButton jRadioButton3;
private javax.swing.JRadioButton kali;
private javax.swing.JRadioButton kurang;
private javax.swing.JRadioButton tambah;
}
and this output like this
thanks for reading guys , i hope this program have many advantages for us :)
Adita Saraswati - 7411030055