pada program dibawah, tidak bisa mnginput sembarangan, karena sudah jelas disini :
if (merk[i].equals("Ink") && tipe[i].equals("Ink Dc"))
harga[i]=150000;
else
if (merk[i].equals("Kyt") && tipe[i].equals("Kyt Troy"))
if (merk[i].equals("Kyt") && tipe[i].equals("Kyt Troy"))
harga[i]=200000;
else
if (merk[i].equals("Arai") && tipe[i].equals("Arai 7x"))
harga[i]=450000;
else
if (merk[i].equals("Bmc") && tipe[i].equals("Bmc Full"))
if (merk[i].equals("Bmc") && tipe[i].equals("Bmc Full"))
harga[i]=100000;
else
if (merk[i].equals("Kbc") && tipe[i].equals("Kbc Race"))
if (merk[i].equals("Kbc") && tipe[i].equals("Kbc Race"))
harga[i]=250000;
else
if (merk[i].equals("Nollan") && tipe[i].equals("Nollan Race"))
if (merk[i].equals("Nollan") && tipe[i].equals("Nollan Race"))
harga[i]=500000;
else
if (merk[i].equals("Agp") && tipe[i].equals("Agp Race"))
if (merk[i].equals("Agp") && tipe[i].equals("Agp Race"))
harga[i]=350000;
else
if (merk[i].equals("Wtc") && tipe[i].equals("Wtc Gold"))
if (merk[i].equals("Wtc") && tipe[i].equals("Wtc Gold"))
================================================
Silakan coba programnya dan Cek, barangkali ada kesalahan :
import javax.swing.*;
public class PenjualanHelm_kaptenteknologi{
public static void main(String[] args){
String [] nama =new String[20];
String [] merk =new String[20];
String [] tipe =new String [20];
int [] jmlbeli =new int [20];
double [] harga =new double[20];
double [] total =new double [20];
String jawab=""; int i=0; int k;
System.out.println("");
System.out.println("***** SELAMAT DATANG DI KAPTENTEKNOLOGI.COM *****");
System.out.println("");
System.out.println(" Helm Yang Tersedia ");
System.out.println("____________________________________________________");
System.out.println(" *---- MERK HELM ----* ");
System.out.println(" 1.Ink");
System.out.println(" 2.Kyt");
System.out.println(" 3.Arai");
System.out.println(" 4.Bmc");
System.out.println(" 5.Kbc");
System.out.println(" 6.Nollan");
System.out.println(" 7.Agp");
System.out.println(" 8.Wtc");
System.out.println("");
System.out.println(" *---- TIPE HELM ----* ");
System.out.println(" 1.Ink Dc");
System.out.println(" 2.Kyt Troy");
System.out.println(" 3.Arai 7x");
System.out.println(" 4.Bmc Full");
System.out.println(" 5.Kbc Race");
System.out.println(" 6.Nollan Race");
System.out.println(" 7.Agp Race");
System.out.println(" 8.Wtc Gold");
System.out.println("____________________________________________________");
do {
nama[i]=JOptionPane.showInputDialog("Nama Pembeli = ");
merk[i]=JOptionPane.showInputDialog("Merk Helm = ");
tipe[i]=JOptionPane.showInputDialog("Tipe Helm = ");
jmlbeli[i]=Integer.valueOf(JOptionPane.showInputDialog("Jumlah Helm yang Dibeli = "));
if (merk[i].equals("Ink") && tipe[i].equals("Ink Dc"))
harga[i]=150000;
else
if (merk[i].equals("Kyt") && tipe[i].equals("Kyt Troy"))
harga[i]=200000;
else
if (merk[i].equals("Arai") && tipe[i].equals("Arai 7x"))
harga[i]=450000;
else
if (merk[i].equals("Bmc") && tipe[i].equals("Bmc Full"))
harga[i]=100000;
else
if (merk[i].equals("Kbc") && tipe[i].equals("Kbc Race"))
harga[i]=250000;
else
if (merk[i].equals("Nollan") && tipe[i].equals("Nollan Race"))
harga[i]=500000;
else
if (merk[i].equals("Agp") && tipe[i].equals("Agp Race"))
harga[i]=350000;
else
if (merk[i].equals("Wtc") && tipe[i].equals("Wtc Gold"))
harga[i]=120000;
else
harga[i]=0;
total[i]=harga[i]*jmlbeli[i];
i++;
jawab=JOptionPane.showInputDialog("Mau Tambah data lagi Y/T");
}
while(jawab.equalsIgnoreCase("Y"));
System.out.println(" # Perhatian Sebelum'nya !! : ");
System.out.println(" ");
System.out.println(" 1. Barang Yang Sudah Dibeli Tidak Dapat Dikembalikan:Kecuali ");
System.out.println(" 2. Barang Ditukar Dengan Jangka Waktu 1 Hari");
System.out.println(" 3. Kami tidak menerima pengembalian helm dalam keadaan cacat");
System.out.println(" ");
System.out.println(" --- Terima Kasih Atas Perhatiannya --- ");
for(int j=0;j
k=j+1;
System.out.println("");
System.out.println(" TOKO KAPTENTEKNOLOGI.COM ");
System.out.println("=========================================");
System.out.println("No\tNama\tMerk Helm\tTipe Helm");
System.out.println("=========================================");
System.out.println(k+"\t"+nama[j]+"\t"+merk[j]+"\t\t"+tipe[j]);
System.out.println("-----------------------------------------");
System.out.println("");
System.out.println("=========================================");
System.out.println("Jumlah Beli\tHarga\t\tTotal");
System.out.println("=========================================");
System.out.println(""+jmlbeli[j]+"\t\t"+harga[j]+"\t"+total[j]);
System.out.println("-----------------------------------------");
System.out.println("");
}
}
}
k=j+1;
System.out.println("");
System.out.println(" TOKO KAPTENTEKNOLOGI.COM ");
System.out.println("=========================================");
System.out.println("No\tNama\tMerk Helm\tTipe Helm");
System.out.println("=========================================");
System.out.println(k+"\t"+nama[j]+"\t"+merk[j]+"\t\t"+tipe[j]);
System.out.println("-----------------------------------------");
System.out.println("");
System.out.println("=========================================");
System.out.println("Jumlah Beli\tHarga\t\tTotal");
System.out.println("=========================================");
System.out.println(""+jmlbeli[j]+"\t\t"+harga[j]+"\t"+total[j]);
System.out.println("-----------------------------------------");
System.out.println("");
}
}
}
Output
mantab ne shob ...
BalasHapusWah kerenn sob.. btw, ane kurang tahu nih.. heheh
BalasHapusmaaf mas error disini mohon perbaikannya
BalasHapusfor(int j=0;j
Maaf ada yang error untuk for (int j=0;;
BalasHapusharap bisa diperbaiki. Blog nya sangat membantu sob. Terimakasih atas Sharing pengetahuannya.
maaf ada yang eror disini(int j=0;j
BalasHapusmohon perbaikannya !!