Friday, June 18, 2010
Quiz Java Netbeans (NURI - 11.7E.01 Kel.B)
---------------------
1. Jenis Makanan :
- Ayam Goreng = Rp. 20.000,-
- Ayam Bakar = Rp. 15.000,-
- Bebek Goreng = Rp. 30.000,-
- Bebek Bakar = Rp. 25.000,-
2. Kemasan :
- Langsung = Diskon 50%
- Pesan = Diskon 10%
Source Code :
----------------
package mykalkulator;
import javax.swing.JOptionPane;
/**
*
* @author aie_sendiri
*/
public class QUIZ_FFOOD extends javax.swing.JFrame {
/** Creates new form QUIZ_FFOOD */
public QUIZ_FFOOD() {
initComponents();
}
1. Pembuatan Method :
@SuppressWarnings("unchecked")
Generated Code
void jenis(){
if(rbtnayam.isSelected() && chidangan.getSelectedItem().toString().equalsIgnoreCase("GORENG")){
txthrg.setText("20000");
txtbeli.requestFocus();
}
else if(rbtnayam.isSelected() && chidangan.getSelectedItem().toString().equalsIgnoreCase("BAKAR")){
txthrg.setText("15000");
txtbeli.requestFocus();
}
else if(rbtnbebek.isSelected() && chidangan.getSelectedItem().toString().equalsIgnoreCase("GORENG")){
txthrg.setText("30000");
txtbeli.requestFocus();
}
else if(rbtnbebek.isSelected() && chidangan.getSelectedItem().toString().equalsIgnoreCase("BAKAR")){
txthrg.setText("25000");
txtbeli.requestFocus();
}
else{
txthrg.setText("0");
}
}
2. Radio Button Ayam :
private void rbtnayamActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jenis();
}
3. Radio Button Bebek :
private void rbtnbebekActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jenis();
}
4. Combo Box Hidangan :
private void chidanganActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
jenis();
}
5. Button Hitung :
private void btnhitungActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int hrg = Integer.parseInt(txthrg.getText());
int beli = Integer.parseInt(txtbeli.getText());
int total = hrg * beli;
txttotal.setText(String.valueOf(total));
if(ckemasan.getSelectedItem().toString().equalsIgnoreCase("LANGSUNG")){
int pot = total * 50/100;
int totber = total - pot;
txtpot.setText(String.valueOf(pot));
txttotber.setText(String.valueOf(totber));
txtbayar.requestFocus();
}
else if(ckemasan.getSelectedItem().toString().equalsIgnoreCase("PESAN")){
int pot = total * 10/100;
int totber = total - pot;
txtpot.setText(String.valueOf(pot));
txttotber.setText(String.valueOf(totber));
txtbayar.requestFocus();
}
else{
txtpot.setText("0");
txttotber.setText("0");
}
}
6. Text Field Bayar :
private void txtbayarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int bayar = Integer.parseInt(txtbayar.getText());
int totber = Integer.parseInt(txttotber.getText());
if(bayar>=totber){
int kembali = bayar - totber;
txtkembali.setText(String.valueOf(kembali));
}
else {
int kurang = JOptionPane.showConfirmDialog(null,"Uang Bayar Kurang !!","PERHATIAN",JOptionPane.OK_CANCEL_OPTION);
if(kurang == JOptionPane.OK_OPTION){
txtbayar.setText("");
txtkembali.setText("");
}
else{
txtbayar.setText("");
txtkembali.setText("");
}
}
}
7. Button Lagi :
private void btnlagiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
btngrpmkn.clearSelection();
chidangan.setSelectedIndex(0);
txthrg.setText("");
txtbeli.setText("");
ckemasan.setSelectedIndex(0);
txttotal.setText("");
txtpot.setText("");
txttotber.setText("");
txtbayar.setText("");
txtkembali.setText("");
rbtnayam.requestFocus();
}
8. Button Keluar :
private void btnkeluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int keluar = JOptionPane.showConfirmDialog(null,"Ingin Keluar ??","Pertanyaan",JOptionPane.YES_NO_OPTION);
if(keluar==JOptionPane.YES_OPTION){
System.exit(0);
}
else{
return;
}
}
Semoga Berguna !!
Saturday, June 12, 2010
Latihan Java - NetBeans : Restoran Cepat Saji "NURI"
Ketentuan soal :
1. Hidangan
--------------------------------
AYAM BAKAR = Rp. 20.000,-
AYAM GULAI = Rp. 15.000,-
BEBEK BAKAR = Rp. 30.000,-
BEBEK GULAI = Rp. 25.000,-
--------------------------------
2. Kemasan
--------------------------------
PESAN = Diskon 10%
LANGSUNG = Diskon 50%
--------------------------------
Source Code :
---------------------------------------------------------------------------------------
package mykalkulator;
import javax.swing.JOptionPane;
/**
*
* @author aie_sendiri
*/
public class FRESTO extends javax.swing.JFrame {
/** Creates new form FRESTO */
public FRESTO() {
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")
// Cara Pembuatan Method :
void hitung(){
if(chidangan.getSelectedItem().toString().equalsIgnoreCase("BAKAR") && rbtnayam.isSelected()){
tharga.setText("20000");
ckemasan.requestFocus();
}
else if(chidangan.getSelectedItem().toString().equalsIgnoreCase("BAKAR") && rbtnbebek.isSelected()){
tharga.setText("30000");
ckemasan.requestFocus();
}
else if(chidangan.getSelectedItem().toString().equalsIgnoreCase("GULAI") && rbtnayam.isSelected()){
tharga.setText("15000");
ckemasan.requestFocus();
}
else if(chidangan.getSelectedItem().toString().equalsIgnoreCase("GULAI") && rbtnbebek.isSelected()){
tharga.setText("25000");
ckemasan.requestFocus();
}
else{
tharga.setText("0");
rbtnayam.requestFocus();
}
}
---------------------------------------------------------------------------------------
1. Radio Button Ayam :
private void rbtnayamActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// Pemanggilan method :
hitung();
}
2. Radio Button Bebek :
private void rbtnbebekActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// Pemanggilan method :
hitung();
}
3. Combo Box Hidangan :
private void chidanganActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
// Pemanggilan method :
hitung();
}
4. Combo Box Kemasan :
private void ckemasanActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(ckemasan.getSelectedItem().toString().equalsIgnoreCase("PESAN")){
int total = Integer.parseInt(tharga.getText());
ttotal.setText(String.valueOf(total));
int pot = total * 10/100;
tpot.setText(String.valueOf(pot));
int totber = total - pot;
ttotber.setText(String.valueOf(totber));
tbayar.requestFocus();
}
else if(ckemasan.getSelectedItem().toString().equalsIgnoreCase("LANGSUNG")){
int total = Integer.parseInt(tharga.getText());
ttotal.setText(String.valueOf(total));
int pot = total * 50/100;
tpot.setText(String.valueOf(pot));
int totber = total - pot;
ttotber.setText(String.valueOf(totber));
tbayar.requestFocus();
}
else{
ttotal.setText("0");
tpot.setText("0");
ttotber.setText("0");
ckemasan.requestFocus();
}
}
5. Text Field Bayar :
private void tbayarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int totber = Integer.parseInt(ttotber.getText());
int bayar = Integer.parseInt(tbayar.getText());
if(bayar>=totber){
int kembali = bayar - totber;
tkembali.setText(String.valueOf(kembali));
}
else{
int validasi = JOptionPane.showConfirmDialog(null,"MAAF, Uang Bayar Kurang !!","Pemberitahuan",JOptionPane.OK_CANCEL_OPTION);
if( validasi==JOptionPane.OK_OPTION){
tbayar.setText("");
tkembali.setText("0");
tbayar.requestFocus();
}
else{
tbayar.setText("");
tkembali.setText("0");
tbayar.requestFocus();
}
}
}
6. Button Bersih :
private void btnbersihActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
btngrpmkn.clearSelection();
chidangan.setSelectedIndex(0);
tharga.setText("0");
ckemasan.setSelectedIndex(0);
ttotal.setText("0");
tpot.setText("0");
ttotber.setText("0");
tbayar.setText("0");
tkembali.setText("0");
rbtnayam.requestFocus();
}
7. Button Keluar :
private void btnkeluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int keluar=JOptionPane.showConfirmDialog(null,"Ingin Keluar?","Pertanyaan",JOptionPane.YES_NO_OPTION);
if(keluar==0){
System.exit(0);
}
else{
return;
}
}
---------------------------------------------------------------------------------------
Sekian.
Tuesday, June 8, 2010
Latihan Java - Net Beans : Aplikasi Klinik NURI (sederhana).
1. Kamar
---------------------------------
-Kode Kamar : BG
-Nama Kamar : Bougenville
---------------------------------
-Kode Kamar : MW
-Nama Kamar : Mawar
---------------------------------
2. Jenis Kamar
---------------------------------
-Jenis Kamar : VIP
-Harga Kamar : 300000
---------------------------------
-Jenis Kamar : Kelas I
-Harga Kamar : 200000
---------------------------------
3. Kode Dokter
---------------------------------
-Kode Dokter : KM
-Nama Dokter : Khanza
---------------------------------
-Kode Dokter : SA
-Nama Dokter : Syahniah
---------------------------------
4. Waktu Praktek
---------------------------------
-Waktu Praktek : PAGI
-Biaya Konsultasi : 50000
---------------------------------
-Waktu Praktek : SORE
-Biaya Konsultasi : 100000
---------------------------------
5. Biaya Lainnya
---------------------------------
-Admin : 10000
-Resep : 10000
-Obat : 50000
---------------------------------
6. Cara Pembayaran
---------------------------------
-Cash : diskon 50%
-Transfer : diskon 10%
---------------------------------
Source Code :
import javax.swing.JOptionPane;
/**
*
* @author aie_sendiri
*/
public class FKLINIK_NURI extends javax.swing.JFrame {
int hrg_kamar, b_konsul, adm, resep, obat, xpot, totyar, total;
double diskon, pot;
/** Creates new form FKLINIK_NURI */
public FKLINIK_NURI() {
initComponents();
}
---------------------------------------------------------------------------------------
1. Combo Box Kode Kamar :
private void ckamarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(ckamar.getSelectedItem().toString().equalsIgnoreCase("bg")){
tkamar.setText("Bougenville");
}
else{
tkamar.setText("Mawar");
}
}
2. Radio Button Type Kamar VIP :
private void rvipActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rvip.isSelected()){
hrg_kamar = 300000;
thrg.setText(String.valueOf(hrg_kamar));
}
}
3. Radio Button Type Kamar Kelas I :
private void rkelasActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rkelas.isSelected()){
hrg_kamar = 200000;
thrg.setText(String.valueOf(hrg_kamar));
}
}
4. Combo Box Kode Dokter :
private void cdokterActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(cdokter.getSelectedItem().toString().equalsIgnoreCase("km")){
tnmdok.setText("KHANZA");
}
else{
tnmdok.setText("SYAHNIAH");
}
}
5. Radio Button Waktu Praktek Pagi :
private void rpagiActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rpagi.isSelected()){
b_konsul = 50000;
tkonsul.setText(String.valueOf(b_konsul));
}
}
6. Radio Button Waktu Praktek Sore :
private void rsoreActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(rsore.isSelected()){
b_konsul = 100000;
tkonsul.setText(String.valueOf(b_konsul));
}
}
7. Check Box ADM :
private void chkadmActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(chkadm.isSelected()){
adm = 10000;
tadm.setText(String.valueOf(adm));
}
else{
adm = 0;
tadm.setText(String.valueOf(adm));
}
}
8. Check Box Resep :
private void chkresepActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(chkresep.isSelected()){
resep = 10000;
tresep.setText(String.valueOf(resep));
}
else{
resep = 0;
tresep.setText(String.valueOf(resep));
}
}
9. Check Box Obat :
private void chkobatActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(chkobat.isSelected()){
obat = 50000;
tobat.setText(String.valueOf(obat));
}
else{
obat = 0;
tobat.setText(String.valueOf(obat));
}
}
10. Combo Box Cara Bayar :
private void cbayarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(cbayar.getSelectedItem().toString().equalsIgnoreCase("cash")){
diskon = 0.5;
total = hrg_kamar + b_konsul + adm + resep + obat;
pot = total * diskon;
xpot = (int)pot;
totyar = total - xpot;
ttotal.setText(String.valueOf(total));
tpot.setText(String.valueOf(xpot));
ttotyar.setText(String.valueOf(totyar));
}
else{
diskon = 0.1;
total = hrg_kamar + b_konsul + adm + resep + obat;
pot = total * diskon;
xpot = (int)pot;
totyar = total - xpot;
ttotal.setText(String.valueOf(total));
tpot.setText(String.valueOf(xpot));
ttotyar.setText(String.valueOf(totyar));
}
}
11. Button Bersih :
private void btnbersihActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
hrg_kamar = 0;
b_konsul = 0;
adm = 0;
resep = 0;
obat = 0;
xpot = 0;
totyar = 0;
total = 0;
diskon = 0;
pot = 0;
ckamar.setSelectedIndex(0);
cdokter.setSelectedIndex(0);
cbayar.setSelectedIndex(0);
btngrpkamar.clearSelection();
btngrpdokter.clearSelection();
tkamar.setText("");
thrg.setText("0");
tnmdok.setText("");
tkonsul.setText("0");
chkadm.setSelected(false);
chkresep.setSelected(false);
chkobat.setSelected(false);
tadm.setText("0");
tresep.setText("0");
tobat.setText("0");
ttotal.setText("0");
tpot.setText("0");
ttotyar.setText("0");
}
12. Button Keluar :
private void btnkeluarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
int answer = JOptionPane.showConfirmDialog(null,"Ingin Keluar?","Pertanyaan",JOptionPane.YES_NO_OPTION);
if(answer == JOptionPane.YES_OPTION){
System.exit(0);
}
else{
return;
}
}
Semoga Bermanfaat !!
Wednesday, June 2, 2010
Latihan Java - Net Beans : Combo Box, Check Box, dan Radio button
Ketentuan Soal :
A. Lokasi dan Harga
1. Blok A = Rp.2,000,000
2. Blok B = Rp.3,000,000
3. Blok C = Rp.4,000,000
B. Fasilitas dan Biaya
1. Jogging Track = Rp. 100,000
2. Swimming Pool = Rp. 200,000
3. Gymnasium = Rp. 300,000
C. Cara Pembayaran
1. Bank Mandiri = Rp. 10,000
2. Other Bank = Rp. 50,000
Source Code :
import javax.swing.JOptionPane;
public class FAPPRUMAH.....bla,... bla,.. bla,...
int hrgdasar, jog, swim, gym, bayar, total;
-------------------------------------------------------------------------------------------
- Combo Box :
if(combo.getSelectedItem().equals("Blok A")){
vhrg = 2000000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
jhrg.setText(String.valueOf(vhrg));
jtotal.setText(String.valueOf(vtotal));
}
else if(combo.getSelectedItem().equals("Blok B")){
vhrg = 3000000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
jhrg.setText(String.valueOf(vhrg));
jtotal.setText(String.valueOf(vtotal));
}
else if(combo.getSelectedItem().equals("Blok C")){
vhrg = 4000000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
jhrg.setText(String.valueOf(vhrg));
jtotal.setText(String.valueOf(vtotal));
}
else{
vhrg = 0;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
jhrg.setText(String.valueOf(vhrg));
jtotal.setText(String.valueOf(vtotal));
}
}
- Check Box Jogging :
if(check1.isSelected()){
vjog = 100000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
jog.setText(String.valueOf(vjog));
jtotal.setText(String.valueOf(vtotal));
}
else{
vjog = 0;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
jog.setText(String.valueOf(vjog));
jtotal.setText(String.valueOf(vtotal));
}
- Check Box Swimming Pool :
if(check2.isSelected()){
vjog = 200000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
swim.setText(String.valueOf(vjog));
jtotal.setText(String.valueOf(vtotal));
}
else{
vjog = 0;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
swim.setText(String.valueOf(vjog));
jtotal.setText(String.valueOf(vtotal));
}
- Check Box Gymnasium :
if(check3.isSelected()){
vjog = 300000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
gym.setText(String.valueOf(vjog));
jtotal.setText(String.valueOf(vtotal));
}
else{
vjog = 0;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
gym.setText(String.valueOf(vjog));
jtotal.setText(String.valueOf(vtotal));
}
- Radio Button Bank Mandiri :
if(btnmandiri.isSelected()){
vbayar = 10000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
bayar.setText(String.valueOf(bayar));
jtotal.setText(String.valueOf(vtotal));
}
- Radio Button Other Bank :
if(btnmandiri.isSelected()){
vbayar = 50000;
vtotal = vhrg + vjog + vswim + vgym + vbayar;
bayar.setText(String.valueOf(bayar));
jtotal.setText(String.valueOf(vtotal));
}
- Button Bersih :
vtotal = 0;
vjog = 0;
vswim = 0;
vgym = 0;
vbayar = 0;
combo.setSelectedItem("-- Pilih --");
jhrg.setText("0");
jog.setText("0");
swim.setText("0");
gym.setText("0");
bayar.setText("0");
jtotal.setText("0");
check1.setSelected(false);
check2..setSelected(false);
check3.setSelected(false);
btngrp.clearSelection();
- Button Keluar :
int x=JOptionPane.showConfirmDialog(null,"Yakin Ingin Keluar??","PERTANYAAN",JOptionPane.YES_NO_OPTION);
if(x==JOptionPane.YES_OPTION){
dispose();
}
else{
return;
}