Lagi ngerjain tugas ya bro. Ini adalah tugas pemrograman visual yaitu membuat program kasir dengan judul Banana Nuget dengan menggunakan java netbeans. Langsung saja kita terjun ke TKP haha..
- Silahkan buat desainnya dahulu seperti gambar dibawah ini[gambar]
- Jika desainnya sudah jadi, pastikan variabel namenya sudah diganti sesuai dengan yang ada pada lembar tugas Banana Nuget
- Selanjutnya klik 2x pada radio button oreo lalu masukan kode dibawah ini[kode]
private void rboreoActionPerformed(java.awt.event.ActionEvent evt) {
// kode oreo@ahmadadha:
int oreo=5000;
if(rboreo.isSelected()){
jtoping.setText(""+rboreo.getText());
jtoping.setText(""+oreo);
}
else{
jtoping.setText("");
}
}
private void rbkejuActionPerformed(java.awt.event.ActionEvent evt) {
// kode keju@ahmadadha:
int keju=3000;
if(rbkeju.isSelected()){
jtoping.setText(""+rbkeju.getText());
jtoping.setText(""+keju);
}
else{
jtoping.setText("");
}
}
private void rbmiloActionPerformed(java.awt.event.ActionEvent evt) {
// kode milo@ahmadadha:
int milo=6000;
if(rbmilo.isSelected()){
jtoping.setText(""+rbmilo.getText());
jtoping.setText(""+milo);
}
else{
jtoping.setText("");
}
}
private void rbnutelaActionPerformed(java.awt.event.ActionEvent evt) {
// kode nutela@ahmadadha:
int nutela=7000;
if(rbnutela.isSelected()){
jtoping.setText(""+rbnutela.getText());
jtoping.setText(""+nutela);
}
else{
jtoping.setText("");
}
}
private void rbcoklatActionPerformed(java.awt.event.ActionEvent evt) {
// kode coklat@ahmadadha:
int coklat=2500;
if(rbcoklat.isSelected()){
jtoping.setText(""+rbcoklat.getText());
jtoping.setText(""+coklat);
}
else{
jtoping.setText("");
}
}
// kode oreo@ahmadadha:
int oreo=5000;
if(rboreo.isSelected()){
jtoping.setText(""+rboreo.getText());
jtoping.setText(""+oreo);
}
else{
jtoping.setText("");
}
}
private void rbkejuActionPerformed(java.awt.event.ActionEvent evt) {
// kode keju@ahmadadha:
int keju=3000;
if(rbkeju.isSelected()){
jtoping.setText(""+rbkeju.getText());
jtoping.setText(""+keju);
}
else{
jtoping.setText("");
}
}
private void rbmiloActionPerformed(java.awt.event.ActionEvent evt) {
// kode milo@ahmadadha:
int milo=6000;
if(rbmilo.isSelected()){
jtoping.setText(""+rbmilo.getText());
jtoping.setText(""+milo);
}
else{
jtoping.setText("");
}
}
private void rbnutelaActionPerformed(java.awt.event.ActionEvent evt) {
// kode nutela@ahmadadha:
int nutela=7000;
if(rbnutela.isSelected()){
jtoping.setText(""+rbnutela.getText());
jtoping.setText(""+nutela);
}
else{
jtoping.setText("");
}
}
private void rbcoklatActionPerformed(java.awt.event.ActionEvent evt) {
// kode coklat@ahmadadha:
int coklat=2500;
if(rbcoklat.isSelected()){
jtoping.setText(""+rbcoklat.getText());
jtoping.setText(""+coklat);
}
else{
jtoping.setText("");
}
}
- Lanjutkan seterusnya hingga kode untuk tiap menu toping sudah terisi
- Jika kode untuk toping sudah selesai, selanjutnya klik 2x pada button hitung dan masukan kodenya dibawah ini[kode]
private void bhitungActionPerformed(java.awt.event.ActionEvent evt) {
// kode hitung@ahmadadha:
int total=0;
if(rboreo.isSelected()){
String rboreo=jbeli.getText();
int jbeli=Integer.parseInt(rboreo);
int jtoping=jbeli * 5000;
total=total+jtoping;
}
if(rbkeju.isSelected()){
String rbkeju=jbeli.getText();
int jbeli=Integer.parseInt(rbkeju);
int jtoping=jbeli * 3000;
total=total+jtoping;
}
if(rbmilo.isSelected()){
String rbmilo=jbeli.getText();
int jbeli=Integer.parseInt(rbmilo);
int jtoping=jbeli * 6000;
total=total+jtoping;
}
if(rbnutela.isSelected()){
String rbnutela=jbeli.getText();
int jbeli=Integer.parseInt(rbnutela);
int jtoping=jbeli * 7000;
total=total+jtoping;
}
if(rbcoklat.isSelected()){
String rbcoklat=jbeli.getText();
int jbeli=Integer.parseInt(rbcoklat);
int jtoping=jbeli * 2500;
total=total+jtoping;
}jharga.setText(""+total);
}
// kode hitung@ahmadadha:
int total=0;
if(rboreo.isSelected()){
String rboreo=jbeli.getText();
int jbeli=Integer.parseInt(rboreo);
int jtoping=jbeli * 5000;
total=total+jtoping;
}
if(rbkeju.isSelected()){
String rbkeju=jbeli.getText();
int jbeli=Integer.parseInt(rbkeju);
int jtoping=jbeli * 3000;
total=total+jtoping;
}
if(rbmilo.isSelected()){
String rbmilo=jbeli.getText();
int jbeli=Integer.parseInt(rbmilo);
int jtoping=jbeli * 6000;
total=total+jtoping;
}
if(rbnutela.isSelected()){
String rbnutela=jbeli.getText();
int jbeli=Integer.parseInt(rbnutela);
int jtoping=jbeli * 7000;
total=total+jtoping;
}
if(rbcoklat.isSelected()){
String rbcoklat=jbeli.getText();
int jbeli=Integer.parseInt(rbcoklat);
int jtoping=jbeli * 2500;
total=total+jtoping;
}jharga.setText(""+total);
}
- Untuk button hapus, kodenya dibawah ini[kode]
private void bhapusActionPerformed(java.awt.event.ActionEvent evt) {
// kode hapus@ahmadadha:
jkasir.setText("");
jbeli.setText("");
rboreo.setSelected(false);
rbkeju.setSelected(false);
rbmilo.setSelected(false);
rbnutela.setSelected(false);
rbcoklat.setSelected(false);
jtoping.setText("");
jharga.setText("");
jbayar.setText("");
jkembali.setText("");
}
// kode hapus@ahmadadha:
jkasir.setText("");
jbeli.setText("");
rboreo.setSelected(false);
rbkeju.setSelected(false);
rbmilo.setSelected(false);
rbnutela.setSelected(false);
rbcoklat.setSelected(false);
jtoping.setText("");
jharga.setText("");
jbayar.setText("");
jkembali.setText("");
}
- Untuk button bayar kodenya dibawah ini[kode]
private void bbayarActionPerformed(java.awt.event.ActionEvent evt) {
// kode bayar@ahmadadha:
int bayar=0;
String ub=jbayar.getText();
String harga=jharga.getText();
int uhar=Integer.parseInt(harga);
int ubayar=Integer.parseInt(ub);
bayar=ubayar-uhar;
jkembali.setText(""+bayar);
}
// kode bayar@ahmadadha:
int bayar=0;
String ub=jbayar.getText();
String harga=jharga.getText();
int uhar=Integer.parseInt(harga);
int ubayar=Integer.parseInt(ub);
bayar=ubayar-uhar;
jkembali.setText(""+bayar);
}
- Untuk button keluar kodenya dibawah ini[kode]
private void bkeluarActionPerformed(java.awt.event.ActionEvent evt) {
// kode keluar@ahmadadha:
int x;
x=JOptionPane.showConfirmDialog(null,"Yakin mau keluar?","Konfirm",JOptionPane.YES_NO_OPTION);
if(x==JOptionPane.YES_NO_OPTION)
dispose();
else
return;
}
// kode keluar@ahmadadha:
int x;
x=JOptionPane.showConfirmDialog(null,"Yakin mau keluar?","Konfirm",JOptionPane.YES_NO_OPTION);
if(x==JOptionPane.YES_NO_OPTION)
dispose();
else
return;
}
Semoga bermanfaat dan jangan lupa share ke teman kamu.
EmoticonEmoticon