Aplikasi Konversi mata uang |
1. Deskripsi
Pengertian konversi mata uang adalah suatu perubahan yang terjadi pada nilai tukar mata uang suatu negara terhadap mata uang negara lainnya. Setiap mata uang memiliki nilai tukar yang berbeda-beda dan akan terus berubah. Terinspirasi dari hal tersebut, Kami mencoba membuat program yang dapat mengkonversi beberapa mata uang, seperti mata uang rupiah ke dolar, euro, poundstrling, dan yen. Hasil konversi nilai mata uang sesuai dengan saat Kami membuat program. Jadi ketika masing-masing nilai mata uang berubah, program yang Kami buat tidak mengikuti update perubahan tersebut. Untuk lebih jelasnya, berikut ini cara membuat program konversi mata uang menggunakan Java NetBeans:
2. Komponen, Variabel, dan Rumus Formula
1. Rupiah
2. Dollar
3. Euro
4. Poundstrling
5. Yen
float rupiah, dollar, euro, poundstrling, yen;
rupiah = Float.parseFloat(TxtRupiah.getText());
dollar = (float)(rupiah*0.000075);
euro = (float)(rupiah*0.000067);
poundstrling = (float)(rupiah*0.000075);
yen = (float)(rupiah*0.0083);
txtDollar.setText(""+ dollar);
txteuro.setText(""+euro);
txtPoundstrling.setText(""+poundstrling);
txtYen.setText(""+yen);
3. Flowchart
4. Source Code
Berikut adalah sourch code Program aplikasi Konversi Mata Uang yang kami buat.
* 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.
*/
package konversi.mata.uang;
/**
*
* @author ade fadiillah_STMIK ERESHA
*/
public class Konversi_Mata_Uang extends javax.swing.JFrame {
float rupiah, dollar, euro, poundstrling, yen;
/**
* Creates new form Konversi_Mata_Uang
*/
public Konversi_Mata_Uang() {
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() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
TxtRupiah = new javax.swing.JTextField();
btnKonversi = new javax.swing.JButton();
txtDollar = new javax.swing.JTextField();
txteuro = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
txtPoundstrling = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
txtYen = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setBackground(new java.awt.Color(204, 204, 204));
jLabel1.setFont(new java.awt.Font("DialogInput", 1, 18)); // NOI18N
jLabel1.setText("Program Konversi Mata Uang");
jLabel2.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
jLabel2.setText("Rupiah");
jLabel4.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
jLabel4.setText("Dollar");
jLabel5.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
jLabel5.setText("Euro");
TxtRupiah.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
btnKonversi.setFont(new java.awt.Font("Calibri", 1, 18)); // NOI18N
btnKonversi.setText("Konversi");
btnKonversi.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnKonversiActionPerformed(evt);
}
});
txtDollar.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
txteuro.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
jLabel6.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
jLabel6.setText("Poundstrling");
txtPoundstrling.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
jLabel7.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
jLabel7.setText("Yen");
txtYen.setFont(new java.awt.Font("Segoe UI Light", 1, 14)); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(51, 51, 51)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jLabel6)
.addComponent(jLabel7))
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtDollar, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.addComponent(TxtRupiah)
.addComponent(txteuro)
.addComponent(txtPoundstrling)
.addComponent(txtYen))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(81, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 336, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(25, 25, 25))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btnKonversi)
.addGap(74, 74, 74))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(32, 32, 32)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(TxtRupiah, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnKonversi)
.addGap(9, 9, 9)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtDollar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(txteuro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel6)
.addComponent(txtPoundstrling, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(txtYen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(31, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
private void btnKonversiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
rupiah = Float.parseFloat(TxtRupiah.getText());
dollar = (float)(rupiah*0.000075);
euro = (float)(rupiah*0.000067);
poundstrling = (float)(rupiah*0.000075);
yen = (float)(rupiah*0.0083);
txtDollar.setText(""+ dollar);
txteuro.setText(""+euro);
txtPoundstrling.setText(""+poundstrling);
txtYen.setText(""+yen);
}
/**
* @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(Konversi_Mata_Uang.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Konversi_Mata_Uang.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Konversi_Mata_Uang.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Konversi_Mata_Uang.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 Konversi_Mata_Uang().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JTextField TxtRupiah;
private javax.swing.JButton btnKonversi;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JTextField txtDollar;
private javax.swing.JTextField txtPoundstrling;
private javax.swing.JTextField txtYen;
private javax.swing.JTextField txteuro;
// End of variables declaration
}
5. Hasil Run (Output)
Berikut adalah gambar screen shot Hasil Run (Output).
Penjelasan :
1. Isi nominal di kolom mata uang Rupiah.
2. Klik button Konversi.
3. Maka Hasil akan keluar di setiap kolom Mata uang asing
Sekian Dan Terima Kasih.
Sekian Dan Terima Kasih.