Posted by : Unknown Kamis, 13 November 2014

KONVERSI SUHU
-------------------------------------------
DESAIN


  RUMUS
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Suhu.java
 *
 * Created on Nov 12, 2014, 7:06:48 PM
 */
/**
 *
 * @author yanuaris mahendra
 */
public class Suhu extends javax.swing.JFrame {

    /** Creates new form Suhu */
    public Suhu() {
        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() {

        hasil2 = new javax.swing.JTextField();
        celcius = new javax.swing.JButton();
        fahrenheit = new javax.swing.JButton();
        reamur = new javax.swing.JButton();
        kelvin = new javax.swing.JButton();
        hasil1 = new javax.swing.JTextField();
        hasil4 = new javax.swing.JTextField();
        hasil3 = new javax.swing.JTextField();
        text1 = new javax.swing.JTextField();
        jButton5 = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setBackground(new java.awt.Color(0, 0, 204));

        celcius.setBackground(new java.awt.Color(0, 0, 204));
        celcius.setText("celcius");
        celcius.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                celciusActionPerformed(evt);
            }
        });

        fahrenheit.setBackground(new java.awt.Color(0, 0, 204));
        fahrenheit.setText("fahrenheit");
        fahrenheit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fahrenheitActionPerformed(evt);
            }
        });

        reamur.setBackground(new java.awt.Color(0, 0, 204));
        reamur.setText("reamur");
        reamur.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reamurActionPerformed(evt);
            }
        });

        kelvin.setBackground(new java.awt.Color(51, 0, 255));
        kelvin.setText("kelvin");
        kelvin.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kelvinActionPerformed(evt);
            }
        });

        hasil1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hasil1ActionPerformed(evt);
            }
        });

        hasil4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hasil4ActionPerformed(evt);
            }
        });

        text1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                text1ActionPerformed(evt);
            }
        });

        jButton5.setBackground(new java.awt.Color(0, 153, 153));
        jButton5.setText("hapus");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(kelvin, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(reamur, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(celcius, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                    .addComponent(fahrenheit, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(56, 56, 56)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(hasil2, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jButton5, javax.swing.GroupLayout.DEFAULT_SIZE, 180, Short.MAX_VALUE)
                        .addGap(26, 26, 26))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(hasil1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(hasil3, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(hasil4, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addContainerGap(224, Short.MAX_VALUE))))
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(text1, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(text1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(45, 45, 45)
                .addComponent(celcius, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(fahrenheit, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(reamur, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(kelvin, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(24, 24, 24))
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(129, Short.MAX_VALUE)
                .addComponent(hasil1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(hasil2, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(hasil3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(hasil4, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(37, 37, 37))
        );

        pack();
    }// </editor-fold>

private void hasil1ActionPerformed(java.awt.event.ActionEvent evt) {                                      
// TODO add your handling code here:
}                                     

private void hasil4ActionPerformed(java.awt.event.ActionEvent evt) {                                      
// TODO add your handling code here:
}                                     

private void text1ActionPerformed(java.awt.event.ActionEvent evt) {                                     
// TODO add your handling code here:
}                                    

private void celciusActionPerformed(java.awt.event.ActionEvent evt) {                                       
// TODO add your handling code here:
        String nilai1 = text1.getText();
   
    int nilai_1 = Integer.parseInt(nilai1);
    double a = nilai_1;//Celcius
    double b = (9 * nilai_1/5) + 32;//Celcius ke Fahrenheit
    double c = 4 * nilai_1/5;//Celcius ke Reamur
    double d = nilai_1 + 273.15;//Celcius ke Kelvin
   
    hasil1.setText(Double.toString(a));
    hasil2.setText(Double.toString(b));
    hasil3.setText(Double.toString(c));
    hasil4.setText(Double.toString(d));

}                                      

private void fahrenheitActionPerformed(java.awt.event.ActionEvent evt) {                                          
// TODO add your handling code here:
        String nilai1 = text1.getText();
   
    int nilai_1 = Integer.parseInt(nilai1);
    double a = 5*(nilai_1 - 32)/9;//Fahrenheit ke Celcius
    double b = nilai_1;//Fahrenheit
    double c = 4*(nilai_1 - 32)/9;//Fahrenheit ke Reamur
    double d = (nilai_1 + 459.67) / 1.8;//Fahrenheit ke Kelvin
   
    hasil1.setText(Double.toString(a));
    hasil2.setText(Double.toString(b));
    hasil3.setText(Double.toString(c));
    hasil4.setText(Double.toString(d));

}                                         

private void reamurActionPerformed(java.awt.event.ActionEvent evt) {                                      
// TODO add your handling code here:
        String nilai1 = text1.getText();
   
    int nilai_1 = Integer.parseInt(nilai1);
    double a = 5 * nilai_1/4;//Reamur ke Celcius
    double b = (9 * nilai_1/4) + 32;//Reamur ke Fahrenheit
    double c = nilai_1;//Reamur
    double d = (5/4*nilai_1)+273;//Reamur ke Kelvin
   
    hasil1.setText(Double.toString(a));
    hasil2.setText(Double.toString(b));
    hasil3.setText(Double.toString(c));
    hasil4.setText(Double.toString(d));

}                                     

private void kelvinActionPerformed(java.awt.event.ActionEvent evt) {                                      
// TODO add your handling code here:
        String nilai1 = text1.getText();
   
    int nilai_1 = Integer.parseInt(nilai1);
    double a = nilai_1 - 273.15;//Kelvin ke Celcius
    double b = (nilai_1 * 1.8) - 459.67;//Kelvin ke Fahrenheit
    double c = 4/5*(nilai_1-273);//Kelvin ke Reamur
    double d = nilai_1;//Kelvin
   
    hasil1.setText(Double.toString(a));
    hasil2.setText(Double.toString(b));
    hasil3.setText(Double.toString(c));
    hasil4.setText(Double.toString(d));

}                                     

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {                                        
// TODO add your handling code here:
        text1.setText(null);
    hasil1.setText(null);
    hasil2.setText(null);
    hasil3.setText(null);
    hasil4.setText(null);

}                                       

    /**
     * @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(Suhu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Suhu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Suhu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Suhu.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 Suhu().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify
    private javax.swing.JButton celcius;
    private javax.swing.JButton fahrenheit;
    private javax.swing.JTextField hasil1;
    private javax.swing.JTextField hasil2;
    private javax.swing.JTextField hasil3;
    private javax.swing.JTextField hasil4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton kelvin;
    private javax.swing.JButton reamur;
    private javax.swing.JTextField text1;
    // End of variables declaration
}
 
*HASIL

{ 1 komentar... read them below or add one }

  1. Best Slots in New Mexico - Pokie Games Near Me
    Find the best casino slot machines in New 카드 카운팅 Mexico. We have a 벤 델핀 list of the bet365 코리아 best online slots in New 스 크릴 Mexico. See what 온라인바카라 casinos are offering here.

    BalasHapus

Welcome to My Blog

Popular Post

Blogger templates

Diberdayakan oleh Blogger.

You can replace this text by going to "Layout" and then "Page Elements" section. Edit " About "

Mbambes

Mbambes

Translate

About Me

Blogger templates

clock

- Copyright © Mbambes BLOG -Robotic Notes- Powered by Blogger - Designed by Johanes Djogan -