BERIKUT PROGRAM TRANSAKSI PEMBAYARAN

Penjelasan Program :
Input : Jumlah Barang dan Harga Barang,
Output : Bayar (Jumlah*Harga) + Pajak 5% dari bayar
(Otomatis),
Keterangan : Mendapat BONUS jika Pembayaran di atas 500.000,
Selain itu tidak dapat BONUS.
PROGRAM KETIKA DI RUN
Program pada saat
input data :
Hasil data inputan setelah diproses
Source Code :
public class pembayaran extends javax.swing.JFrame {
/**
* Creates new
form pembayaran
*/
public
pembayaran() {
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();
txtjml = new
javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
txtharga = new
javax.swing.JTextField();
jLabel4 = new
javax.swing.JLabel();
txtpajak = new
javax.swing.JTextField();
jLabel5 = new
javax.swing.JLabel();
txtket = new
javax.swing.JTextField();
btnhitung =
new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel1.setText("TRANSAKSI PEMBAYARAN");
jLabel2.setText("Jumlah Barang");
txtjml.addActionListener(new java.awt.event.ActionListener() {
public
void actionPerformed(java.awt.event.ActionEvent evt) {
txtjmlActionPerformed(evt);
}
});
jLabel3.setText("Harga Barang");
txtharga.addActionListener(new java.awt.event.ActionListener() {
public
void actionPerformed(java.awt.event.ActionEvent evt) {
txthargaActionPerformed(evt);
}
});
jLabel4.setText("Bayar Pajak + 5%");
txtpajak.addActionListener(new java.awt.event.ActionListener() {
public
void actionPerformed(java.awt.event.ActionEvent evt) {
txtpajakActionPerformed(evt);
}
});
jLabel5.setText("KETERANGAN");
txtket.addActionListener(new java.awt.event.ActionListener() {
public
void actionPerformed(java.awt.event.ActionEvent evt) {
txtketActionPerformed(evt);
}
});
btnhitung.setText("HITUNG");
btnhitung.addActionListener(new java.awt.event.ActionListener() {
public
void actionPerformed(java.awt.event.ActionEvent evt) {
btnhitungActionPerformed(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()
.addGap(73, 73, 73)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel5)
.addComponent(jLabel4))
.addGap(23, 23, 23)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtpajak)
.addComponent(txtket, javax.swing.GroupLayout.DEFAULT_SIZE, 242,
Short.MAX_VALUE)))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel3))
.addGap(43, 43, 43)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
.addComponent(txtjml, javax.swing.GroupLayout.DEFAULT_SIZE, 155,
Short.MAX_VALUE)
.addComponent(txtharga))
.addGap(0, 0, Short.MAX_VALUE)))
.addGap(48, 48, 48))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnhitung)
.addGap(154, 154, 154))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING,
layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1)
.addGap(123, 123, 123))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jLabel1)
.addGap(36,
36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtjml, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(txtharga, javax.swing.GroupLayout.PREFERRED_SIZE,
javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btnhitung)
.addGap(13, 13, 13)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(txtpajak,
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)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel5)
.addGap(0, 61, Short.MAX_VALUE))
.addComponent(txtket))
.addContainerGap())
);
pack();
}//
</editor-fold>
private void
txthargaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
}
private void
txtpajakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
}
private void
txtketActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
}
private void
btnhitungActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add
your handling code here:
int
jumlah,harga,bayar,pajak;
jumlah =
Integer.parseInt(txtjml.getText());
harga=Integer.parseInt(txtharga.getText());
pajak=(jumlah*harga)*5/100;
bayar=jumlah*harga+pajak;
txtpajak.setText(""+bayar);
if(bayar
> 500000){txtket.setText("DAPAT BONUS");}
else {txtket.setText("TIDAK DAPAT
BONUS");
}
}
private void
txtjmlActionPerformed(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(pembayaran.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(InstantiationException ex) {
java.util.logging.Logger.getLogger(pembayaran.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(IllegalAccessException ex) {
java.util.logging.Logger.getLogger(pembayaran.class.getName()).log(java.util.logging.Level.SEVERE,
null, ex);
} catch
(javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(pembayaran.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
pembayaran().setVisible(true);
}
});
}
// Variables declaration - do not modify
private
javax.swing.JButton btnhitung;
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.JTextField txtharga;
private
javax.swing.JTextField txtjml;
private
javax.swing.JTextField txtket;
private
javax.swing.JTextField txtpajak;
// End of
variables declaration
}