0% found this document useful (0 votes)
29 views

Tugas Java

This document contains the code for a Java program that calculates hospital room rates and total costs based on room type, patient type, and length of stay. It includes code blocks that handle selections from dropdown menus and radio buttons to determine the room rate, multiply the rate by the length of stay to calculate the total, and include buttons to restart or exit the program.

Uploaded by

cahyoenggar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Tugas Java

This document contains the code for a Java program that calculates hospital room rates and total costs based on room type, patient type, and length of stay. It includes code blocks that handle selections from dropdown menus and radio buttons to determine the room rate, multiply the rate by the length of stay to calculate the total, and include buttons to restart or exit the program.

Uploaded by

cahyoenggar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

Nama: Cahyo Enggar Nugroho NIM : 11101263

Kelas : 11.5AB.01.D Tampilan Program :

Code :

public class kamar_pasien extends javax.swing.JFrame { String kode, ruangan; int tarif, total; //KODE KAMAR private void cbkodeActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(cbkode.getSelectedItem().equals("KKA")) { tjenis.setText("VIP"); cbruangan.removeAllItems(); cbruangan.addItem("Permata"); cbruangan.addItem("Berlian"); } else if(cbkode.getSelectedItem().equals("KKB")) { tjenis.setText("Kelas 1"); cbruangan.removeAllItems(); cbruangan.addItem("Melati"); cbruangan.addItem("Anggrek"); } else { tjenis.setText("Kelas 2"); cbruangan.removeAllItems(); cbruangan.addItem("Merah"); cbruangan.addItem("Putih"); } }

//KODE RADIO BUTTON ANAK

private void ranakActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(ranak.isSelected()) { if(cbkode.getSelectedItem().equals("KKA")) { if(cbruangan.getSelectedItem().equals("Permata")) { tarif=400000; } else { tarif=300000; } } else if(cbkode.getSelectedItem().equals("KKB")) { if(cbruangan.getSelectedItem().equals("Melati")) { tarif=275000; } else { tarif=250000; } } else { if(cbruangan.getSelectedItem().equals("Merah")) {

tarif=200000; } else { tarif=150000; } } ttarif.setText(String.valueOf(tarif)); } } //KODE RADIO BUTTON DEWASA private void rdewasaActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: if(rdewasa.isSelected()) { if(cbkode.getSelectedItem().equals("KKA")) { if(cbruangan.getSelectedItem().equals("Permata")) { tarif=600000; } else { tarif=500000; } } else if(cbkode.getSelectedItem().equals("KKB")) { if(cbruangan.getSelectedItem().equals("Melati")) {

tarif=375000; } else { tarif=350000; } } else { if(cbruangan.getSelectedItem().equals("Merah")) { tarif=300000; } else { tarif=250000; } } ttarif.setText(String.valueOf(tarif)); } } //KODE HITUNG LAMA INAP private void tlamainapActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: total=Integer.parseInt(tlamainap.getText()) * tarif; ttotbay.setText(String.valueOf(total)); }

//KODE BUTTON LAGI

private void blagiActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: tnama.setText(""); cbkode.setSelectedItem("KKA"); tjenis.setText(""); cbruangan.setSelectedItem("Permata"); buttonGroup1.clearSelection(); ttarif.setText(""); tlamainap.setText(""); ttotbay.setText(""); }

//KODE BUTTON KELUAR private void bselesaiActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: int a=JOptionPane.showConfirmDialog(null, "Keluar Dari Program?", "Konfirmasi", JOptionPane.YES_NO_OPTION); if(a==JOptionPane.YES_OPTION) System.exit('0'); else return; }

You might also like