UAS Membuat Program Aritmatika dengan NetBeans


UAS ALGORITMA DAN TEKNIK PEMROGRAMAN



Membuat program sederhana yang menerima 2 inputan berupa bilangan bulat kemudian dari bilangan tersebut dilakukan operasi aritmatika +,-,/,dan *.

Dari hasil operasi aritmatika tersebut akan menampilkan jumlahnya dan menentukan apakah hasilnya bilangan genap atau ganjil.

Source Code program :


import java.sql.DatabaseMetaData;

import java.util.Scanner;

import javafx.beans.binding.Bindings;

import javax.swing.JTextField;

import javax.swing.text.html.HTML;


/*

 * To change this license header, choose License Headers in Project Properties.

 * To change this template file, choose Tools | Templates

 * and open the template in the editor.

 */


/**

 *

 * @author Ferry Ananda Febian

 */

public class Main_Kalkulator extends javax.swing.JFrame {


    String angka;

    double jumlah;

    double angka1;

    double angka2;

    int pilih;

    int bil;

    /**

     * Creates new form Main_Kalkulator

     */

    public Main_Kalkulator() {

        initComponents();

    }


    /**

     * This method is called from within the constructor to initialize the form.

     * WARNING: Do NOT modify this code. The content of this method is always

     * regenerated by the Form Editor.

     */

    @SuppressWarnings("unchecked")

    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          

    private void initComponents() {


        jPanel1 = new javax.swing.JPanel();

        jTF_tampil = new javax.swing.JTextField();

        jB_hapus = new javax.swing.JButton();

        jB_bagi = new javax.swing.JButton();

        jB_kali = new javax.swing.JButton();

        jB_kurang = new javax.swing.JButton();

        jB_tambah = new javax.swing.JButton();

        jB_samaDengan = new javax.swing.JButton();

        jB_9 = new javax.swing.JButton();

        jB_8 = new javax.swing.JButton();

        jB_7 = new javax.swing.JButton();

        jB_4 = new javax.swing.JButton();

        jB_5 = new javax.swing.JButton();

        jB_6 = new javax.swing.JButton();

        jB_3 = new javax.swing.JButton();

        jB_2 = new javax.swing.JButton();

        jB_1 = new javax.swing.JButton();

        jB_koma = new javax.swing.JButton();

        jB_0 = new javax.swing.JButton();

        ganjilgenap = new javax.swing.JTextField();


        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        setTitle("Kalkulator_Sederhana");

        setResizable(false);

        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());


        jPanel1.setBackground(new java.awt.Color(102, 102, 102));


        jTF_tampil.setEditable(false);

        jTF_tampil.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jTF_tampil.setHorizontalAlignment(javax.swing.JTextField.RIGHT);

        jTF_tampil.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jTF_tampilActionPerformed(evt);

            }

        });


        jB_hapus.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_hapus.setText("C");

        jB_hapus.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_hapusActionPerformed(evt);

            }

        });


        jB_bagi.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_bagi.setText("/");

        jB_bagi.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_bagiActionPerformed(evt);

            }

        });


        jB_kali.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_kali.setText("X");

        jB_kali.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_kaliActionPerformed(evt);

            }

        });


        jB_kurang.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_kurang.setText("-");

        jB_kurang.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_kurangActionPerformed(evt);

            }

        });


        jB_tambah.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_tambah.setText("+");

        jB_tambah.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_tambahActionPerformed(evt);

            }

        });


        jB_samaDengan.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_samaDengan.setText("=");

        jB_samaDengan.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_samaDenganActionPerformed(evt);

            }

        });


        jB_9.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_9.setText("9");

        jB_9.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_9ActionPerformed(evt);

            }

        });


        jB_8.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_8.setText("8");

        jB_8.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_8ActionPerformed(evt);

            }

        });


        jB_7.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_7.setText("7");

        jB_7.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_7ActionPerformed(evt);

            }

        });


        jB_4.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_4.setText("4");

        jB_4.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_4ActionPerformed(evt);

            }

        });


        jB_5.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_5.setText("5");

        jB_5.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_5ActionPerformed(evt);

            }

        });


        jB_6.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_6.setText("6");

        jB_6.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_6ActionPerformed(evt);

            }

        });


        jB_3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_3.setText("3");

        jB_3.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_3ActionPerformed(evt);

            }

        });


        jB_2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_2.setText("2");

        jB_2.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_2ActionPerformed(evt);

            }

        });


        jB_1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_1.setText("1");

        jB_1.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_1ActionPerformed(evt);

            }

        });


        jB_koma.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_koma.setText(",");

        jB_koma.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_komaActionPerformed(evt);

            }

        });


        jB_0.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N

        jB_0.setText("0");

        jB_0.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                jB_0ActionPerformed(evt);

            }

        });


        ganjilgenap.setBackground(new java.awt.Color(240, 240, 240));

        ganjilgenap.addActionListener(new java.awt.event.ActionListener() {

            public void actionPerformed(java.awt.event.ActionEvent evt) {

                ganjilgenapActionPerformed(evt);

            }

        });


        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);

        jPanel1.setLayout(jPanel1Layout);

        jPanel1Layout.setHorizontalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel1Layout.createSequentialGroup()

                .addContainerGap()

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)

                    .addComponent(ganjilgenap)

                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addComponent(jB_0, javax.swing.GroupLayout.PREFERRED_SIZE, 112, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                                .addComponent(jB_koma, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addComponent(jB_1, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                .addComponent(jB_2, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                                .addComponent(jB_3, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addComponent(jB_4, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                .addComponent(jB_5, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                                .addComponent(jB_6, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))

                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(jB_kurang, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(jB_tambah, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(jB_samaDengan, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))

                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)

                            .addGroup(jPanel1Layout.createSequentialGroup()

                                .addComponent(jB_7, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                                .addComponent(jB_8, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                                .addComponent(jB_9, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))

                            .addComponent(jB_hapus, javax.swing.GroupLayout.PREFERRED_SIZE, 171, javax.swing.GroupLayout.PREFERRED_SIZE))

                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                            .addComponent(jB_bagi, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)

                            .addComponent(jB_kali, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE)))

                    .addComponent(jTF_tampil))

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );

        jPanel1Layout.setVerticalGroup(

            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

            .addGroup(jPanel1Layout.createSequentialGroup()

                .addContainerGap()

                .addComponent(jTF_tampil, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addComponent(ganjilgenap, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jB_bagi, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_hapus, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jB_7, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_8, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_9, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_kali, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jB_kurang, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_6, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_5, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_4, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jB_tambah, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_3, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_2, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                    .addComponent(jB_0, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_koma, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)

                    .addComponent(jB_samaDengan, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))

                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

        );


        getContentPane().add(jPanel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 250, 340));


        pack();

    }// </editor-fold>                        


    private void jB_0ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "0";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_1ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "1";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_2ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "2";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_3ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "3";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_4ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "4";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_5ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "5";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_6ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "6";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_7ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "7";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_8ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "8";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_9ActionPerformed(java.awt.event.ActionEvent evt) {                                     

        // TODO add your handling code here:

        angka += "9";

        jTF_tampil.setText(angka);

    }                                    


    private void jB_komaActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:

        angka += ".";

        jTF_tampil.setText(angka);

    }                                       


    private void jB_hapusActionPerformed(java.awt.event.ActionEvent evt) {                                         

        // TODO add your handling code here:

        jTF_tampil.setText("");

        angka1 = 0.0;

        angka2 = 0.0;

        jumlah = 0.0;

        angka = "";

        ganjilgenap.setText("");

    }                                        


    private void jB_tambahActionPerformed(java.awt.event.ActionEvent evt) {                                          

        // TODO add your handling code here:

        angka1 = Double.parseDouble(angka);

        jTF_tampil.setText("+");

        angka = "";

        pilih = 1;

    }                                         


    private void jB_kurangActionPerformed(java.awt.event.ActionEvent evt) {                                          

        // TODO add your handling code here:

        angka1 = Double.parseDouble(angka);

        jTF_tampil.setText("-");

        angka = "";

        pilih = 2;

    }                                         


    private void jB_kaliActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:

        angka1 = Double.parseDouble(angka);

        jTF_tampil.setText("x");

        angka = "";

        pilih = 3;

    }                                       


    private void jB_bagiActionPerformed(java.awt.event.ActionEvent evt) {                                        

        // TODO add your handling code here:

        angka1 = Double.parseDouble(angka);

        jTF_tampil.setText("/");

        angka = "";

        pilih = 4;

    }                                       


    private void jB_samaDenganActionPerformed(java.awt.event.ActionEvent evt) {                                              

        // TODO add your handling code here:

        switch (pilih){

            case 1:

                angka2 = Double.parseDouble(angka);

                jumlah = angka1 + angka2;

                angka = Double.toString(jumlah);

                jTF_tampil.setText(angka);

                bil = (int) (angka1 + angka2);

                if (bil%2!=0){

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan ganjil");

                } else {

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan genap");

                }

                break;

            case 2:

                angka2 = Double.parseDouble(angka);

                jumlah = angka1 - angka2;

                angka = Double.toString(jumlah);

                jTF_tampil.setText(angka);

                bil = (int) (angka1 - angka2);

                if (bil%2!=0){

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan ganjil");

                } else {

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan genap");

                }

                break;

            case 3:

                angka2 = Double.parseDouble(angka);

                jumlah = angka1 * angka2;

                angka = Double.toString(jumlah);

                jTF_tampil.setText(angka);

                bil = (int) (angka1 * angka2);

                if (bil%2!=0){

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan ganjil");

                } else {

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan genap");

                }

                break;

            case 4:

                angka2 = Double.parseDouble(angka);

                jumlah = angka1 / angka2;

                angka = Double.toString(jumlah);

                jTF_tampil.setText(angka);

                bil = (int) (angka1 / angka2);

                if (bil%2!=0){

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan ganjil");

                } else {

                    ganjilgenap.setText("Bilangan "+bil+" adalah bilangan genap");

                }

                break;

            default:

                break;

        }

    }                                             


    private void jTF_tampilActionPerformed(java.awt.event.ActionEvent evt) {                                           

        // TODO add your handling code here:

    }                                          


    private void ganjilgenapActionPerformed(java.awt.event.ActionEvent evt) {                                            

        // TODO add your handling code here:

    }                                           


    /**

     * @param args the command line arguments

     */

    public static void main(String args[]) {

        /* Set the Nimbus look and feel */

        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">

        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 

         */

        try {

            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {

                if ("Nimbus".equals(info.getName())) {

                    javax.swing.UIManager.setLookAndFeel(info.getClassName());

                    break;

                }

            }

        } catch (ClassNotFoundException ex) {

            java.util.logging.Logger.getLogger(Main_Kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (InstantiationException ex) {

            java.util.logging.Logger.getLogger(Main_Kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (IllegalAccessException ex) {

            java.util.logging.Logger.getLogger(Main_Kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        } catch (javax.swing.UnsupportedLookAndFeelException ex) {

            java.util.logging.Logger.getLogger(Main_Kalkulator.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);

        }

        //</editor-fold>


        /* Create and display the form */

        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {

                new Main_Kalkulator().setVisible(true);

            }

        });

    }


    // Variables declaration - do not modify                     

    private javax.swing.JTextField ganjilgenap;

    private javax.swing.JButton jB_0;

    private javax.swing.JButton jB_1;

    private javax.swing.JButton jB_2;

    private javax.swing.JButton jB_3;

    private javax.swing.JButton jB_4;

    private javax.swing.JButton jB_5;

    private javax.swing.JButton jB_6;

    private javax.swing.JButton jB_7;

    private javax.swing.JButton jB_8;

    private javax.swing.JButton jB_9;

    private javax.swing.JButton jB_bagi;

    private javax.swing.JButton jB_hapus;

    private javax.swing.JButton jB_kali;

    private javax.swing.JButton jB_koma;

    private javax.swing.JButton jB_kurang;

    private javax.swing.JButton jB_samaDengan;

    private javax.swing.JButton jB_tambah;

    private javax.swing.JPanel jPanel1;

    private javax.swing.JTextField jTF_tampil;

    // End of variables declaration                   


    private void bil(JTextField jTF_tampil) {

        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.

    }

}


Output Program :

Proses aritmatika penjumlahan (5 + 5) = 10

Proses aritmatika pengurangan (12 - 7)= 5

Proses aritmatika perkalian (5 * 6) = 30

Proses aritmatika pembagian (9 / 9)= 1


Posting Komentar

0 Komentar