Aplikasi Pemesanan Tiket Kereta Api(KA)
● Judul/Nama Aplikasi
Pemesanan
Tiket KA
● Tujuan Aplikasi Pemesanan Tiket KA
Aplikasi
Pemesanan Tiket KA dibuat untuk memudahkan pengguna Kereta Api jarak jauh dalam
membeli tiket kereta. Jadi, yang biasanya pengguna membeli tiket harus pergi ke
Stasiun terlebih dahulu sekarang tinggal membuka Aplikasi tersebut tidak perlu
pergi ke Stasiun lagi.
● Cara Penggunaan Aplikasi Pemesanan Tiket KA
Cara
penguunannya buka terlebih dahulu aplikasi pemesanan tiket KA, jika sudah akan
ditampilkan beberapa kolom yang harus anda isi. Pertama ketik nama anda
terlebih dahulu, lalu pilih Kode Kereta sesuai tujuan yang akan anda tuju. Lalu
dilanjutkan memilih jurusan, disediakan dua jurusan dalam satu kode kereta.
Setelah itu memilih jenis tiket yang akan di beli tiket untuk dewasa atau
anak-anak, jika sudah memilih secara otomatis akan tampil harga tiket di kolom “Harga”.
Dilanjutkan untuk mengetik jumlah tiket yang akan dibeli di kolom “Jumlah Beli”,
dan tekan “Enter” untuk menampilkan total harga yang anda harus bayar. Klik “Keluar”
jika sudah dirasa memenuhi tiket yang ingin dipesan, atau klik “Beli Lagi”
untuk kembali memesan tiket.
● Flowchart
● Coding java
public class Kereta_Jarak_Jauh extends javax.swing.JFrame {
int a,b,c,hanak,hdewasa;
/**
* Creates new form Kereta_Jarak_Jauh
*/
public Kereta_Jarak_Jauh() {
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() {
btnganakdewasa = new javax.swing.ButtonGroup();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
tnama = new javax.swing.JTextField();
tkereta = new javax.swing.JTextField();
tjumlahbeli = new javax.swing.JTextField();
ttotalbayar = new javax.swing.JTextField();
bbersih = new javax.swing.JButton();
jcbokode = new javax.swing.JComboBox<>();
jcbojurusan = new javax.swing.JComboBox<>();
bkeluar = new javax.swing.JButton();
tduit = new javax.swing.JTextField();
rddanak = new javax.swing.JRadioButton();
rdddewasa = new javax.swing.JRadioButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
jLabel1.setText("PEMESANAN TIKET KA");
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel2.setText("Nama");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel3.setText("Kode Kereta");
jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel4.setText("Nama Kereta");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel5.setText("Jurusan");
jLabel6.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel6.setText("Jenis Tiket");
jLabel7.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel7.setText("Harga");
jLabel8.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel8.setText("Jumlah Beli");
jLabel9.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jLabel9.setText("Total Bayar");
tnama.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
tkereta.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
tjumlahbeli.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
tjumlahbeli.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
tjumlahbeliActionPerformed(evt);
}
});
ttotalbayar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
bbersih.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
bbersih.setText("Beli Lagi");
bbersih.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bbersihActionPerformed(evt);
}
});
jcbokode.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jcbokode.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "---- Pilih Kode ----", "KA111", "KA222", "KA333" }));
jcbokode.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jcbokodeActionPerformed(evt);
}
});
jcbojurusan.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
jcbojurusan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jcbojurusanActionPerformed(evt);
}
});
bkeluar.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
bkeluar.setText("Keluar");
bkeluar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
bkeluarActionPerformed(evt);
}
});
btnganakdewasa.add(rddanak);
rddanak.setText("Anak-Anak");
rddanak.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rddanakActionPerformed(evt);
}
});
btnganakdewasa.add(rdddewasa);
rdddewasa.setText("Dewasa");
rdddewasa.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
rdddewasaActionPerformed(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(65, 65, 65)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel2)
.addComponent(jLabel4)
.addComponent(jLabel7)
.addComponent(jLabel8)
.addComponent(jLabel6)
.addComponent(jLabel3)
.addComponent(jLabel5))
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(tjumlahbeli, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(73, 73, 73)
.addComponent(jLabel9)
.addGap(18, 18, 18)
.addComponent(ttotalbayar, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(jcbojurusan, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jcbokode, 0, 155, Short.MAX_VALUE)
.addComponent(tnama, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tkereta, javax.swing.GroupLayout.Alignment.LEADING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(bbersih, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(bkeluar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGap(28, 28, 28))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tduit, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(rddanak)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(rdddewasa)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(layout.createSequentialGroup()
.addGap(148, 148, 148)
.addComponent(jLabel1)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jLabel1)
.addGap(29, 29, 29)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(tnama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bbersih))
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jcbokode, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bkeluar))
.addGap(17, 17, 17)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(tkereta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(62, 62, 62)
.addComponent(jLabel5))
.addComponent(jcbojurusan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(26, 26, 26)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(rddanak)
.addComponent(rdddewasa)))
.addGap(36, 36, 36)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel7)
.addComponent(tduit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(jLabel9)
.addComponent(tjumlahbeli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(ttotalbayar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(38, 38, 38))
);
pack();
}// </editor-fold>
private void jcbokodeActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(jcbokode.getSelectedItem().equals("KA111")){
tkereta.setText("MATARMAJA");
jcbojurusan.removeAllItems();
jcbojurusan.addItem("---- Jurusan ----");
jcbojurusan.addItem("PASAR SENEN - KEDIRI");
jcbojurusan.addItem("PASAR SENEN - MADIUN");
}
else if(jcbokode.getSelectedItem().equals("KA222")){
tkereta.setText("BIMA");
jcbojurusan.removeAllItems();
jcbojurusan.addItem("---- Jurusan ----");
jcbojurusan.addItem("TANAH ABANG - TEGAL");
jcbojurusan.addItem("TANAH ABANG - KEDIRI");
}
else if(jcbokode.getSelectedItem().equals("KA333")){
tkereta.setText("BENGAWAN");
jcbojurusan.removeAllItems();
jcbojurusan.addItem("---- Jurusan ----");
jcbojurusan.addItem("GAMBIR - KUTOARJO");
jcbojurusan.addItem("GAMBIR - LEMPUYANGAN");
}
else if(jcbokode.getSelectedItem().equals("---- Pilih Kode ----")){
}
}
private void jcbojurusanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(jcbojurusan.getSelectedItem().equals("---- JURUSAN ----")){
btnganakdewasa.clearSelection();
tduit.setText("");
}
else if(jcbojurusan.getSelectedItem().equals("PASAR SENEN - KEDIRI")){
hanak=30000;
hdewasa=60000;
}
else if(jcbojurusan.getSelectedItem().equals("PASAR SENEN - MADIUN")){
hanak=35000;
hdewasa=65000;
}
else if(jcbojurusan.getSelectedItem().equals("TANAH ABANG - TEGAL")){
hanak=40000;
hdewasa=70000;
}
else if(jcbojurusan.getSelectedItem().equals("TANAH ABANG - KEDIRI")){
hanak=45000;
hdewasa=75000;
}
else if(jcbojurusan.getSelectedItem().equals("GAMBIR - KUTOARJO")){
hanak=50000;
hdewasa=80000;
}
else if(jcbojurusan.getSelectedItem().equals("GAMBIR - LEMPUYANGAN")){
hanak=55000;
hdewasa=850000;
}
}
private void bbersihActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
tnama.setText("");
jcbokode.setSelectedItem("---- Pilih Kode ----");
tkereta.setText("");
jcbojurusan.removeAllItems();
btnganakdewasa.clearSelection();
tduit.setText("");
tjumlahbeli.setText("");
ttotalbayar.setText("");
}
private void tjumlahbeliActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
a=Integer.parseInt(tduit.getText());
b=Integer.parseInt(tjumlahbeli.getText());
c=a*b;
ttotalbayar.setText(String.valueOf(c));
}
private void bkeluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
dispose();
}
private void rddanakActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rddanak.isSelected()){
tduit.setText(String.valueOf(hanak));
}
}
private void rdddewasaActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rdddewasa.isSelected()){
tduit.setText(String.valueOf(hdewasa));
}
}
/**
* @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(Kereta_Jarak_Jauh.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Kereta_Jarak_Jauh.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Kereta_Jarak_Jauh.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Kereta_Jarak_Jauh.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 Kereta_Jarak_Jauh().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton bbersih;
private javax.swing.JButton bkeluar;
private javax.swing.ButtonGroup btnganakdewasa;
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.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JComboBox<String> jcbojurusan;
private javax.swing.JComboBox<String> jcbokode;
private javax.swing.JRadioButton rddanak;
private javax.swing.JRadioButton rdddewasa;
private javax.swing.JTextField tduit;
private javax.swing.JTextField tjumlahbeli;
private javax.swing.JTextField tkereta;
private javax.swing.JTextField tnama;
private javax.swing.JTextField ttotalbayar;
// End of variables declaration
}
● Output
Komentar
Posting Komentar