Professional Documents
Culture Documents
Ukk Pbo
Ukk Pbo
CODING
/*
* 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 javaapplication9;
import java.awt.Event;
import java.awt.TextArea;
import java.awt.TextField;
/**
*
* @author ACER
*/
public class kasir1 extends javax.swing.JFrame {
/**
* Creates new form kasir1
*/
public kasir1() {
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("No Faktur");
jLabel2.setText("Jenis Bayar");
jLabel3.setText("Nama Barang");
jLabel4.setText("Harga");
jLabel5.setText("Kuantitas");
jLabel6.setText("Diskon");
jLabel7.setText("Jumlah bayar");
nofkturtxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
nofkturtxtActionPerformed(evt);
}
});
namabrgtxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
namabrgtxtActionPerformed(evt);
}
});
kualitastxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
kualitastxtActionPerformed(evt);
}
});
hargatxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
hargatxtActionPerformed(evt);
}
});
diskontxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
diskontxtActionPerformed(evt);
}
});
jumlahbayartxt.setText("0");
jumlahbayartxt.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jumlahbayartxtActionPerformed(evt);
}
});
printbtn.setText("Print");
printbtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
printbtnActionPerformed(evt);
}
});
clearbtn.setText("Clear");
clearbtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clearbtnActionPerformed(evt);
}
});
exitbtn.setText("Exit");
exitbtn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitbtnActionPerformed(evt);
}
});
outputarea.setColumns(20);
outputarea.setRows(5);
jScrollPane1.setViewportView(outputarea);
pack();
}// </editor-fold>
String f = nofkturtxt.getText();
String b = (String) jenisbox.getSelectedItem();
String nb = namabrgtxt.getText();
k = Integer.parseInt(kualitastxt.getText());
d = Double.parseDouble(diskontxt.getText());
h = Integer.parseInt(hargatxt.getText());
jb = Integer.parseInt(jumlahbayartxt.getText());
jb = (h * k) - d;
jumlahbayartxt.setText(""+jb);
outputarea.setText("No Faktur\t : "+f+"\nNama Barang\t : "+nb+
"\nKuantitas\t : "+k+"\nHarga\t : "+h+
"\n Jenis Bayar\t : "+b+"\nDiskon\t : "+d+
"\nJumlah Bayar\t : Rp."+jb);
}
a = Integer.parseInt(kualitastxt.getText());
b = Integer.parseInt(hargatxt.getText());
c = a*b;
jb = String.valueOf(jenisbox.getSelectedItem());
if (jb.equals("Tunai")){
disc = 0.15*c;
} else if (jb.equals("Debit Rekening")){
disc = 0.1*c;
} else if (jb.equals("Kartu Kredit")){
disc = 0.2*c;
} else if (jb.equals("Internet Banking")) {
disc = 0.15*c;
} else if (jb.equals("SMS Banking")){
disc = 0.2*c;
} else {
disc = 0;
}
diskontxt.setText(""+disc);
}
/**
* @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(kasir1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(kasir1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(kasir1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(kasir1.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
OUTPUT
TUGAS 2
CODINGAN
/*
* 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 javaapplication9;
import java.awt.Event;
import java.awt.TextArea;
import java.awt.TextField;
/**
*
* @author ACER
*/
public class kasir2 extends javax.swing.JFrame {
/**
* Creates new form kasir2
*/
public kasir2() {
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() {
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setBackground(new java.awt.Color(0, 102, 102));
jLabel1.setText("No Pelanggan");
jLabel2.setText("Jenis Pembayaran");
jLabel3.setText("Paket");
jLabel4.setText("Frekuensi Pembayaran");
jLabel5.setText("Sewa Jasa");
jLabel6.setText("Diskon");
jLabel7.setText("Administrasi");
jLabel8.setText("Total");
jenis.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Tunai", "Debit Rekening", "Kartu Kredit", "Via
ATM" }));
jenis.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jenisActionPerformed(evt);
}
});
diskon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
diskonActionPerformed(evt);
}
});
admin.setText("Rp. 3000");
total.setText("0");
print.setText("Print");
print.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
printActionPerformed(evt);
}
});
clear.setText("Clear");
clear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
clearActionPerformed(evt);
}
});
exit.setText("Exit");
exit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
exitActionPerformed(evt);
}
});
output.setColumns(20);
output.setRows(5);
jScrollPane1.setViewportView(output);
pack();
}// </editor-fold>
fps = String.valueOf(frekuensi.getSelectedItem());
if (fps.equals("Bulanan")){
dis = 0;
} else if (fps.equals("Triwulan")){
dis = 0.3;
} else if (fps.equals("Semester")){
dis = 0.5;
} else if (fps.equals("Tahunan")){
dis = 1;
} else {
dis = 0;
}
String p = noplng.getText();
String dist = diskon.getText();
String jb = (String) jenis.getSelectedItem();
String adm = admin.getText();
String pkt = (String) paket.getSelectedItem();
String fp = (String) frekuensi.getSelectedItem();
j = Integer.parseInt(sewa.getText());
tt = Integer.parseInt(total.getText());
tt = j - (j * dis) + 3000;
total.setText(""+tt);
output.setText("No Pelanggan\t : "+p+"\nJenis Pembayar\t : "+jb+
"\nPaket\t : "+pkt+"\nFrekuensi Pembayaran\t : "+fp+
"\n Sewa Jasa\t : "+j+"\nDiskon\t : "+dist+"\n Administrasi\t : "+adm+
"\nTotal Tagihan\t : Rp."+tt);
String pkt;
int pak;
pkt = String.valueOf(paket.getSelectedItem());
if (pkt.equals("Mars")){
pak = 120000;
} else if (pkt.equals("Venus")){
pak = 150000;
} else if (pkt.equals("Earth")){
pak = 170000;
} else if (pkt.equals("Jupiter")){
pak = 249000;
} else {
pak = 0;
}
sewa.setText(""+pak);
}
d1 = String.valueOf(frekuensi.getSelectedItem());
if (d1.equals("Bulanan")){
ok = "Tidak ada";
} else if (d1.equals("Triwulan")){
ok = "30%";
} else if (d1.equals("Semester")){
ok = "50%";
} else if (d1.equals("Tahunan")){
ok = "1 Bulan";
} else {
ok = "";
}
diskon.setText(""+ok);
}
/**
* @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(kasir2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(kasir2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(kasir2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(kasir2.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
OUTPUT